Merge pull request #15 from rickeylev:fix-bazel-5-exec-info
PiperOrigin-RevId: 513882714
diff --git a/README.md b/README.md
index 6ab3a29..e51b91f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+[![Build
+status](https://badge.buildkite.com/a82ebafd30ad56e0596dcd3a3a19f36985d064f7f7fb89e21e.svg)](https://buildkite.com/bazel/rules-testing)
+
# Testing Rule's Implementation
Use this framework to test a rule's implementation function.
diff --git a/lib/truth.bzl b/lib/truth.bzl
index c6f6ef7..2af336f 100644
--- a/lib/truth.bzl
+++ b/lib/truth.bzl
@@ -143,8 +143,9 @@
A struct representing an `Expect` object.
"""
- # buildifier: disable=uninitialized
meta = meta or _expect_meta_new(env)
+
+ # buildifier: disable=uninitialized
public = struct(
# keep sorted start
meta = meta,
diff --git a/lib/util.bzl b/lib/util.bzl
index 0320581..10ad201 100644
--- a/lib/util.bzl
+++ b/lib/util.bzl
@@ -222,6 +222,7 @@
)
def _skip_test_impl(ctx):
+ _ = ctx # @unused
fail("Should have been skipped")
_skip_test = rule(
diff --git a/tests/truth_tests.bzl b/tests/truth_tests.bzl
index 713294d..4534192 100644
--- a/tests/truth_tests.bzl
+++ b/tests/truth_tests.bzl
@@ -17,25 +17,13 @@
load("@bazel_skylib//lib:unittest.bzl", ut_asserts = "asserts")
load("//lib:truth.bzl", "matching", "subjects", "truth")
load("//lib:analysis_test.bzl", "analysis_test", "test_suite")
-load("//lib:util.bzl", "util")
+# Bazel 5 has a bug where every access of testing.ExecutionInfo is a new
+# object that isn't equal to itself. This is fixed in Bazel 6.
_IS_BAZEL_6_OR_HIGHER = (testing.ExecutionInfo == testing.ExecutionInfo)
_suite = []
-_TEST_FILES_ATTR = {
- "test_files": attr.label(
- default = ":truth_tests_data_files",
- allow_files = True,
- ),
-}
-_HELPER_ATTR = {
- "_helper": attr.label(
- default = ":truth_tests_helper",
- aspects = [util.testing_aspect],
- ),
-}
-
def _fake_env(env):
failures = []
env1 = struct(
@@ -1202,7 +1190,7 @@
subject = truth.expect(fake_env).that_target(target)
# First a static string, no formatting parameters
- result = subject.action_generating("third_party/bazel_rules/rules_testing/tests/default_runfile1.txt")
+ result = subject.action_generating("{package}/default_runfile1.txt")
ut_asserts.true(env, result != None, msg = "action_generating gave None")
# Now try it with formatting parameters
@@ -1308,20 +1296,6 @@
)
fake_env.reset()
-def _fake_action(outputs = depset()):
- return struct(
- mnemonic = "FakeAction",
- outputs = outputs,
- argv = None,
- )
-
-def _fake_ctx(attrs = struct()):
- return struct(
- label = Label("//fake/tests:fake_test"),
- workspace_name = "fake_workspace",
- attr = attrs,
- )
-
def _test_helper_impl(ctx):
action_output = ctx.actions.declare_file("action.txt")
ctx.actions.run(