mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
fix: fixes tinygo test ./... syntax.
This commit is contained in:
committed by
Ron Evans
parent
1b2e764835
commit
a07287d3c6
@@ -13,6 +13,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
@@ -520,6 +521,46 @@ func ioLogger(t *testing.T, wg *sync.WaitGroup) io.WriteCloser {
|
||||
return w
|
||||
}
|
||||
|
||||
func TestGetListOfPackages(t *testing.T) {
|
||||
opts := optionsFromTarget("", sema)
|
||||
tests := []struct {
|
||||
pkgs []string
|
||||
expectedPkgs []string
|
||||
expectesError bool
|
||||
}{
|
||||
{
|
||||
pkgs: []string{"./tests/testing/recurse/..."},
|
||||
expectedPkgs: []string{
|
||||
"github.com/tinygo-org/tinygo/tests/testing/recurse",
|
||||
"github.com/tinygo-org/tinygo/tests/testing/recurse/subdir",
|
||||
},
|
||||
},
|
||||
{
|
||||
pkgs: []string{"./tests/testing/pass"},
|
||||
expectedPkgs: []string{
|
||||
"github.com/tinygo-org/tinygo/tests/testing/pass",
|
||||
},
|
||||
},
|
||||
{
|
||||
pkgs: []string{"./tests/testing"},
|
||||
expectesError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
actualPkgs, err := getListOfPackages(test.pkgs, &opts)
|
||||
if err != nil && !test.expectesError {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
} else if err == nil && test.expectesError {
|
||||
t.Error("expected error, but got none")
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(test.expectedPkgs, actualPkgs) {
|
||||
t.Errorf("expected two slices to be equal, expected %v got %v", test.expectedPkgs, actualPkgs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This TestMain is necessary because TinyGo may also be invoked to run certain
|
||||
// LLVM tools in a separate process. Not capturing these invocations would lead
|
||||
// to recursive tests.
|
||||
|
||||
Reference in New Issue
Block a user