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

buildifier: Resolve unit test flake in TestFindConfigPath #1160

Merged
merged 2 commits into from
Apr 25, 2023
Merged

buildifier: Resolve unit test flake in TestFindConfigPath #1160

merged 2 commits into from
Apr 25, 2023

Conversation

LINKIWI
Copy link
Contributor

@LINKIWI LINKIWI commented Apr 25, 2023

The following buildifier unit test has been flaking in my CI, with symptom:

$ bazel test //...
INFO: Invocation ID: 0c41e58f-9ab7-4337-9787-aa525e5e80a3
INFO: Analyzed 128 targets (0 packages loaded, 0 targets configured).
INFO: Found 105 targets and 23 test targets...
FAIL: //buildifier/config:go_default_test (see /mnt/ssd0/cache/bazel/_bazel_kiwi/c4dc02d2b3fe20521581445ef560a9ba/execroot/com_github_bazelbuild_buildtools/bazel-out/k8-fastbuild/testlogs/buildifier/config/go_default_test/test.log)
INFO: Elapsed time: 0.987s, Critical Path: 0.93s
INFO: 24 processes: 8 disk cache hit, 24 linux-sandbox.
INFO: Build completed, 1 test FAILED, 24 total actions
//api_proto:api.gen.pb.go_checkshtest                                    PASSED in 0.0s
//build:go_default_test                                                  PASSED in 0.1s
//build_proto:build.gen.pb.go_checkshtest                                PASSED in 0.0s
//buildifier:buildifier_integration_test                                 PASSED in 0.1s
//buildifier/npm:integration_test                                        PASSED in 0.1s
//buildifier/utils:go_default_test                                       PASSED in 0.0s
//buildozer:buildozer_test                                               PASSED in 0.9s
//buildozer/npm:integration_test                                         PASSED in 0.1s
//bzlenv:bzlenv_test                                                     PASSED in 0.0s
//bzlenv:go_default_test                                                 PASSED in 0.0s
//deps_proto:deps.gen.pb.go_checkshtest                                  PASSED in 0.0s
//edit:go_default_test                                                   PASSED in 0.1s
//edit/bzlmod:go_default_test                                            PASSED in 0.0s
//extra_actions_base_proto:extra_actions_base.gen.pb.go_checkshtest      PASSED in 0.0s
//labels:go_default_test                                                 PASSED in 0.0s
//lang:tables.gen.go_checkshtest                                         PASSED in 0.0s
//tables:go_default_test                                                 PASSED in 0.0s
//unused_deps:go_default_test                                            PASSED in 0.0s
//unused_deps:jar_manifest_test                                          PASSED in 0.0s
//warn:go_default_test                                                   PASSED in 0.2s
//warn/docs:go_default_test                                              PASSED in 0.0s
//wspace:go_default_test                                                 PASSED in 0.0s
//buildifier/config:go_default_test                                      FAILED in 0.0s
  /mnt/ssd0/cache/bazel/_bazel_kiwi/c4dc02d2b3fe20521581445ef560a9ba/execroot/com_github_bazelbuild_buildtools/bazel-out/k8-fastbuild/testlogs/buildifier/config/go_default_test/test.log

Executed 23 out of 23 tests: 22 tests pass and 1 fails locally.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.

The test output is:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //buildifier/config:go_default_test
-----------------------------------------------------------------------------
--- FAIL: TestFindConfigPath (0.00s)
    --- FAIL: TestFindConfigPath/no-config-file (0.00s)
        config_test.go:494: tmp: /tmp/no-config-file131613270
        config_test.go:514: FindConfigPath: want "", got ".buildifier2.json"
FAIL

This seems to be a side effect of the environment improperly leaking across test cases; unsetting the environment after os.Setenv seems to resolve this.

Copy link
Member

@vladmos vladmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@vladmos vladmos merged commit 3dcc8d6 into bazelbuild:master Apr 25, 2023
apattidb pushed a commit to databricks/buildtools that referenced this pull request May 10, 2024
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 this pull request may close these issues.

2 participants