Skip to content

Commit

Permalink
fix muzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
123liuziming committed Aug 10, 2024
1 parent d5d79cc commit 2247cd4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions test/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ func RunInstrument(t *testing.T, args ...string) {
}
}

func TBuildAppNoop(t *testing.T, appName, mainClass string) {
func TBuildAppNoop(t *testing.T, appName string, muzzleClasses ...string) {
UseApp(appName)
if mainClass == "" {
if muzzleClasses == nil || len(muzzleClasses) == 0 {
RunInstrument(t)
} else {
RunInstrument(t, "--", mainClass)
RunInstrument(t, muzzleClasses...)
}
}

Expand Down Expand Up @@ -242,7 +242,7 @@ func ExpectContainsNothing(t *testing.T, actualItems []string) {
}
}

func ExecMuzzle(t *testing.T, dependencyName, moduleName string, minVersion, maxVersion *version.Version, mainClass string) {
func ExecMuzzle(t *testing.T, dependencyName, moduleName string, minVersion, maxVersion *version.Version, muzzleClasses []string) {
if testing.Short() {
t.Skip()
return
Expand Down Expand Up @@ -272,7 +272,7 @@ func ExecMuzzle(t *testing.T, dependencyName, moduleName string, minVersion, max
t.Logf("testing on version %v\n", version.Original())
UseApp(moduleName + "/" + testVersion.Original())
FetchVersion(t, dependencyName, version.Original())
TBuildAppNoop(t, moduleName+"/"+testVersion.Original(), mainClass)
TBuildAppNoop(t, moduleName+"/"+testVersion.Original(), muzzleClasses...)
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestMuzzle(t *testing.T) {
continue
}
t.Run(c.TestName, func(t *testing.T) {
ExecMuzzle(t, c.DependencyName, c.ModuleName, c.MinVersion, c.MaxVersion, c.MuzzleMainClass)
ExecMuzzle(t, c.DependencyName, c.ModuleName, c.MinVersion, c.MaxVersion, c.MuzzleClasses)
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/mongo_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ func init() {
TestCases = append(TestCases, NewGeneralTestCase("mongo-1.11.1-crud-test", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", TestCrudMongo),
NewGeneralTestCase("mongo-1.11.1-cursor-test", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", TestCursor),
NewGeneralTestCase("mongo-1.11.1-batch-test", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", TestBatch),
NewMuzzleTestCase("mongo-1.11.1-muzzle", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", ""),
NewMuzzleTestCase("mongo-1.11.1-crud-muzzle", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", []string{"test_crud_mongo.go", "dsn.go"}),
NewMuzzleTestCase("mongo-1.11.1-cursor-muzzle", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", []string{"test_batch.go", "dsn.go"}),
NewMuzzleTestCase("mongo-1.11.1-batch-muzzle", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", []string{"test_cursor.go", "dsn.go"}),
NewLatestDepthTestCase("mongo-1.11.1-latestDepth", mongo_dependency_name, mongo_module_name, "v1.11.1", "v1.15.1", "1.18", "", TestCrudMongo))
}

Expand Down
6 changes: 3 additions & 3 deletions test/test_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type TestCase struct {
MaxGoVersion *version.Version
TestFunc func(t *testing.T, env ...string)
LatestDepthFunc func(t *testing.T, env ...string)
MuzzleMainClass string
MuzzleClasses []string
IsMuzzleCheck bool
IsLatestDepthCheck bool
}
Expand Down Expand Up @@ -61,10 +61,10 @@ func NewGeneralTestCase(testName, dependencyName, moduleName, minVersion, maxVer
}
}

func NewMuzzleTestCase(testName, dependencyName, moduleName, minVersion, maxVersion, minGoVersion, maxGoVersion, mainClass string) *TestCase {
func NewMuzzleTestCase(testName, dependencyName, moduleName, minVersion, maxVersion, minGoVersion, maxGoVersion string, muzzleClasses []string) *TestCase {
c := NewGeneralTestCase(testName, dependencyName, moduleName, minVersion, maxVersion, minGoVersion, maxGoVersion, nil)
c.IsMuzzleCheck = true
c.MuzzleMainClass = mainClass
c.MuzzleClasses = muzzleClasses
return c
}

Expand Down

0 comments on commit 2247cd4

Please sign in to comment.