Skip to content

testing: tests that panic sometimes log "warning: no tests to run" instead #41479

@dmitshur

Description

@dmitshur

The TestScript/test_exit test in cmd/go failed on the linux-386-longtest builder in https://build.golang.org/log/6f34555f06c618921fe4b9e85fbe1522a1a8078e because a panic wasn't seen:

--- FAIL: TestScript (0.00s)
    --- FAIL: TestScript/test_exit (0.78s)
        script_test.go:211: 
            # Builds and runs test binaries, so skip in short mode. (0.000s)
            # If a test invoked by 'go test' exits with a zero status code,
            # it will panic. (0.777s)
            > ! go test ./zero
            [stdout]
            --- FAIL: TestExitZero (0.00s)
            testing: warning: no tests to run
            FAIL
            FAIL	m/zero	0.024s
            FAIL
            [exit status 1]
            > ! stdout ^ok
            > ! stdout 'exit status'
            > stdout 'panic'
            FAIL: testdata/script/test_exit.txt:11: no match for `(?m)panic` found in stdout
            
FAIL
FAIL	cmd/go	99.358s

The passing behavior for that test is something like:

# If a test invoked by 'go test' exits with a zero status code,
# it will panic. (0.418s)
> ! go test ./zero
[stdout]
--- FAIL: TestExitZero (0.00s)
panic: unexpected call to os.Exit(0) during test [recovered]
panic: unexpected call to os.Exit(0) during test

Another failure on linux-386-longtest builder around 20 commits ago in https://build.golang.org/log/63ec772b8d735f614581991b172dc91b86f64b5c also involved not finding panic in stdout:

--- FAIL: TestScript (0.00s)
    --- FAIL: TestScript/test_cleanup_failnow (0.79s)
        script_test.go:211: 
            # For issue 41355 (0.787s)
            > [short] skip
            > ! go test -v cleanup_failnow/panic_nocleanup_test.go
            [stdout]
            === RUN   TestX
            === RUN   TestX/x
            --- FAIL: TestX (0.00s)
                --- FAIL: TestX/x (0.00s)
            --- FAIL: TestX (0.00s)
            testing: warning: no tests to run
            FAIL
            FAIL	command-line-arguments	0.041s
            FAIL
            [exit status 1]
            > stdout '(?s)panic: die \[recovered\].*panic: die'
            FAIL: testdata/script/test_cleanup_failnow.txt:5: no match for `(?m)(?s)panic: die \[recovered\].*panic: die` found in stdout
            
FAIL
FAIL	cmd/go	86.983s

Not sure if the issue is in cmd/go or the runtime.

/cc @bcmills

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions