Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add newline in error message between code path and actual failed line in test file #37

Closed
msbutler opened this issue Mar 24, 2022 · 1 comment · Fixed by #38
Closed

Comments

@msbutler
Copy link
Contributor

Currently, data driven tests return an error message that looks like:

    --- FAIL: TestBackupRestoreDataDriven/column-families (7.88s)
        backup_test.go:283: 
            /private/var/tmp/_bazel_michaelbutler/13ba282fa2b19539d0c969c1113bb37c/sandbox/darwin-sandbox/1/execroot/cockroach/bazel-out/darwin-fastbuild/bin/pkg/ccl/backupccl/backupccl_test_/backupccl_test.runfiles/cockroach/pkg/ccl/backupccl/testdata/backup-restore/column-families:52: SELECT max(length(start_key)) FROM [SHOW RANGES FROM TABLE r1.cfs];
            expected:
            2
            
            found:
            <nil>
    backup_test.go:379: -- test log scope end --
FAIL
I220324 21:54:59.442315 1 (gostd) testmain.go:432  [-] 1  Test //pkg/ccl/backupccl:backupccl_test exited with error code 1


ERROR: <nil>

202 runs completed, 1 failures, over 2m37s
context canceled
FAIL

A more user friendly error would add a newline between the code path and the actual line that failed, i.e. (you can see the SELECT statement in question below):

    --- FAIL: TestBackupRestoreDataDriven/column-families (7.88s)
        backup_test.go:283: 
            /private/var/tmp/_bazel_michaelbutler/13ba282fa2b19539d0c969c1113bb37c/sandbox/darwin-sandbox/1/execroot/cockroach/bazel-out/darwin-fastbuild/bin/pkg/ccl/backupccl/backupccl_test_/backupccl_test.runfiles/cockroach/pkg/ccl/backupccl/testdata/backup-restore/column-families:52: 
           SELECT max(length(start_key)) FROM [SHOW RANGES FROM TABLE r1.cfs];
            expected:
            2
            
            found:
            <nil>
    backup_test.go:379: -- test log scope end --
FAIL
I220324 21:54:59.442315 1 (gostd) testmain.go:432  [-] 1  Test //pkg/ccl/backupccl:backupccl_test exited with error code 1


ERROR: <nil>

202 runs completed, 1 failures, over 2m37s
context canceled
FAIL

The lack of newline lead to some confusion diagnosing a data driven test failure: here and here.

@msbutler
Copy link
Contributor Author

msbutler commented Mar 24, 2022

i beleive the fix is adding another \n between the first and second arg in the string on https://github.com/cockroachdb/datadriven/blob/master/datadriven.go#L369

happy to open a PR with the fix if folks think this would be a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant