MCPcopy
hub / github.com/tinygo-org/tinygo / TestGetListOfPackages

Function TestGetListOfPackages

main_test.go:1054–1092  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1052}
1053
1054func TestGetListOfPackages(t *testing.T) {
1055 opts := optionsFromTarget("", sema)
1056 tests := []struct {
1057 pkgs []string
1058 expectedPkgs []string
1059 expectesError bool
1060 }{
1061 {
1062 pkgs: []string{"./tests/testing/recurse/..."},
1063 expectedPkgs: []string{
1064 "github.com/tinygo-org/tinygo/tests/testing/recurse",
1065 "github.com/tinygo-org/tinygo/tests/testing/recurse/subdir",
1066 },
1067 },
1068 {
1069 pkgs: []string{"./tests/testing/pass"},
1070 expectedPkgs: []string{
1071 "github.com/tinygo-org/tinygo/tests/testing/pass",
1072 },
1073 },
1074 {
1075 pkgs: []string{"./tests/testing"},
1076 expectesError: true,
1077 },
1078 }
1079
1080 for _, test := range tests {
1081 actualPkgs, err := getListOfPackages(test.pkgs, &opts)
1082 if err != nil && !test.expectesError {
1083 t.Errorf("unexpected error: %v", err)
1084 } else if err == nil && test.expectesError {
1085 t.Error("expected error, but got none")
1086 }
1087
1088 if !reflect.DeepEqual(test.expectedPkgs, actualPkgs) {
1089 t.Errorf("expected two slices to be equal, expected %v got %v", test.expectedPkgs, actualPkgs)
1090 }
1091 }
1092}
1093
1094// This TestMain is necessary because TinyGo may also be invoked to run certain
1095// LLVM tools in a separate process. Not capturing these invocations would lead

Callers

nothing calls this directly

Calls 4

optionsFromTargetFunction · 0.85
getListOfPackagesFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected