Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum authored Oct 8, 2024
1 parent 994cb41 commit 7d62507
Showing 1 changed file with 2 additions and 50 deletions.
52 changes: 2 additions & 50 deletions src/test/shell/bazel/starlark_repository_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,7 @@ function test_incompatible_no_implicit_watch_label() {
echo nothing > ${outside_dir}/data.txt

create_new_workspace
cat > $(setup_module_dot_bazel) <<EOF
cat > MODULE.bazel <<EOF
foo = use_repo_rule("//:r.bzl", "foo")
foo(name = "foo")
bar = use_repo_rule("//:r.bzl", "bar")
Expand Down Expand Up @@ -2916,7 +2916,7 @@ function test_no_incompatible_no_implicit_watch_label() {
echo nothing > ${outside_dir}/data.txt

create_new_workspace
cat > $(setup_module_dot_bazel) <<EOF
cat > MODULE.bazel <<EOF
foo = use_repo_rule("//:r.bzl", "foo")
foo(name = "foo")
bar = use_repo_rule("//:r.bzl", "bar")
Expand Down Expand Up @@ -2954,54 +2954,6 @@ EOF
expect_log "I see:"
}

function test_bad_marker_file_ignored() {
# when reading a file in another repo, we should watch it.
local outside_dir="${TEST_TMPDIR}/outside_dir"
mkdir -p "${outside_dir}"
echo nothing > ${outside_dir}/data.txt

create_new_workspace
cat > $(setup_module_dot_bazel) <<EOF
foo = use_repo_rule("//:r.bzl", "foo")
foo(name = "foo")
bar = use_repo_rule("//:r.bzl", "bar")
bar(name = "bar", data = "nothing")
EOF
touch BUILD
cat > r.bzl <<EOF
def _foo(rctx):
rctx.file("BUILD", "filegroup(name='foo')")
# intentionally grab a file that's not directly addressable by a label
otherfile = rctx.path(Label("@bar//subpkg:BUILD")).dirname.dirname.get_child("data.txt")
print("I see: " + rctx.read(otherfile))
foo=repository_rule(_foo)
def _bar(rctx):
rctx.file("subpkg/BUILD")
rctx.file("data.txt", rctx.attr.data)
bar=repository_rule(_bar, attrs={"data":attr.string()})
EOF

bazel build @foo >& $TEST_log || fail "expected bazel to succeed"
expect_log "I see: nothing"

local marker_file=$(bazel info output_base)/external/@+_repo_rules+foo.marker
# the marker file for this repo should contain a reference to "@@+_repo_rules+bar". Mangle that.
sed -i'' -e 's/@@+_repo_rules+bar/@@LOL@@LOL/g' ${marker_file}

# Running Bazel again shouldn't crash, and should result in a refetch.
bazel shutdown
bazel build @foo >& $TEST_log || fail "expected bazel to succeed"
expect_log "I see: nothing"

# Test to clear the marker file.
echo > ${marker_file}

# Running Bazel again shouldn't crash, and should result in a refetch.
bazel shutdown
bazel build @foo >& $TEST_log || fail "expected bazel to succeed"
expect_log "I see: nothing"
}

function test_file_watching_in_undefined_repo() {
create_new_workspace
cat > MODULE.bazel <<EOF
Expand Down

0 comments on commit 7d62507

Please sign in to comment.