bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Test timeout causes build failure in "bazel coverage"

Open linzhp opened this issue 4 years ago • 1 comments
trafficstars

Description of the problem / feature request:

When a test is run under bazel coverage and times out, Bazel reports it as a build failure (exit code 1) instead of a test failure (exit code 3), because the expected output coverage.dat was not created. This is undesirable because all other tests will be skipped once a build failure is seen. Furthermore, it confuses the post-processing tools, making them mistakenly categorize the failure.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

On a workspace:

-- BUILD.bazel --
load("@io_bazel_rules_go//go:def.bzl", "go_test")

sh_test(
  name = "sh_default_test",
  size = "small",
  srcs = ["long_test.sh"],
)

go_test(
  name = "go_default_test",
  srcs = ["long_test.go"],
  size = "small",
)
-- long_test.go --
package timeout

import (
        "time"
        "testing"
)

func TestLong(t *testing.T) {
        time.Sleep(2 * time.Second)
}
-- long_test.sh --
sleep 2s
-- WORKSPACE --
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "7904dbecbaffd068651916dce77ff3437679f9d20e1a7956bff43826e7645fcc",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
    ],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.15.7")

Run:

bazel coverage --test_timeout=1,-1,-1,-1 //:sh_default_test 
echo $?
bazel coverage --test_timeout=1,-1,-1,-1 //:go_default_test
echo $?

What operating system are you running Bazel on?

macOS

What's the output of bazel info release?

release 4.0.0-homebrew

linzhp avatar Jan 26 '21 20:01 linzhp

cc @c-mita

comius avatar Aug 08 '22 10:08 comius

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

github-actions[bot] avatar Oct 13 '23 01:10 github-actions[bot]

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!

github-actions[bot] avatar Jan 11 '24 01:01 github-actions[bot]