Skip to content

Commit

Permalink
refactor, Always use inner-most "testing.T" object so test errors are…
Browse files Browse the repository at this point in the history
… reported properly
  • Loading branch information
bauersimon committed Oct 22, 2024
1 parent e76cd17 commit 142443d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions model/symflower/symflower_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestModelGenerateTestsForFile(t *testing.T) {
ExpectedAssessment metrics.Assessments
ExpectedCoverage uint64
ExpectedError error
ExpectedErrorHandler func(err error)
ExpectedErrorHandler func(t *testing.T, err error)
}

validate := func(t *testing.T, tc *testCase) {
Expand All @@ -59,7 +59,7 @@ func TestModelGenerateTestsForFile(t *testing.T) {
}

if tc.Model == nil {
tc.Model = NewModel()
tc.Model = NewModelSymbolicExecution()
}
ctx := model.Context{
Language: tc.Language,
Expand All @@ -74,7 +74,7 @@ func TestModelGenerateTestsForFile(t *testing.T) {
if tc.ExpectedError != nil {
assert.ErrorIs(t, tc.ExpectedError, actualError)
} else if tc.ExpectedErrorHandler != nil {
tc.ExpectedErrorHandler(actualError)
tc.ExpectedErrorHandler(t, actualError)
} else {
require.NoError(t, actualError)

Expand Down Expand Up @@ -129,7 +129,7 @@ func TestModelGenerateTestsForFile(t *testing.T) {
RepositoryPath: filepath.Join("..", "..", "testdata", "java", "light"),
FilePath: filepath.Join("src", "main", "java", "com", "eval", "Knapsack.java"),

ExpectedErrorHandler: func(err error) {
ExpectedErrorHandler: func(t *testing.T, err error) {
if osutil.IsWindows() {
isProcessKilled := strings.Contains(err.Error(), context.DeadlineExceeded.Error()) || strings.Contains(err.Error(), "exit status 1")
assert.True(t, err != nil && isProcessKilled)
Expand Down

0 comments on commit 142443d

Please sign in to comment.