@@ -41,11 +41,19 @@ func TestTimeout(t *testing.T) {
4141 t .Skip ("stack traces on timeouts are not yet supported on Windows" )
4242 }
4343
44- if err := bazel_testing .RunBazel ("test" , "//:timeout_test" , "--test_timeout=3" ); err == nil {
44+ var stderr string
45+ if err := bazel_testing .RunBazel ("test" , "//:timeout_test" , "--test_timeout=3" , "--test_arg=-test.v" ); err == nil {
4546 t .Fatal ("expected bazel test to fail" )
4647 } else if exitErr , ok := err .(* bazel_testing.StderrExitError ); ! ok || exitErr .Err .ExitCode () != 3 {
4748 t .Fatalf ("expected bazel test to fail with exit code 3" , err )
49+ } else {
50+ stderr = string (exitErr .Err .Stderr )
4851 }
52+
53+ if ! strings .Contains (stderr , "TIMEOUT: //:timeout_test" ) {
54+ t .Errorf ("expect Bazel to report the test timed out: \n %s" , stderr )
55+ }
56+
4957 p , err := bazel_testing .BazelOutput ("info" , "bazel-testlogs" )
5058 if err != nil {
5159 t .Fatalf ("could not find testlogs root: %s" , err )
@@ -57,10 +65,21 @@ func TestTimeout(t *testing.T) {
5765 }
5866
5967 testLog := string (b )
60- if ! strings .Contains (testLog , "Received SIGTERM, printing stack traces of all goroutines: " ) {
61- t .Fatalf ("test log does not contain expected header:\n %s" , testLog )
68+ if ! strings .Contains (testLog , "panic: test timed out after 3s " ) {
69+ t .Errorf ("test log does not contain expected header:\n %s" , testLog )
6270 }
6371 if ! strings .Contains (testLog , "timeout_test.neverTerminates(" ) {
64- t .Fatalf ("test log does not contain expected stack trace:\n %s" , testLog )
72+ t .Errorf ("test log does not contain expected stack trace:\n %s" , testLog )
73+ }
74+
75+ path = filepath .Join (strings .TrimSpace (string (p )), "timeout_test/test.xml" )
76+ b , err = os .ReadFile (path )
77+ if err != nil {
78+ t .Fatalf ("could not read test XML: %s" , err )
79+ }
80+
81+ testXML := string (b )
82+ if ! strings .Contains (testXML , `<testcase classname="timeout_test" name="TestFoo"` ) {
83+ t .Errorf ("test XML does not contain expected element:\n %s" , testXML )
6584 }
6685}
0 commit comments