diff --git a/src/test/shell/bazel/local_repository_test.sh b/src/test/shell/bazel/local_repository_test.sh index cd456e6cedd93f..61e827c616c60e 100755 --- a/src/test/shell/bazel/local_repository_test.sh +++ b/src/test/shell/bazel/local_repository_test.sh @@ -22,12 +22,16 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CURRENT_DIR}/../integration_test_setup.sh" \ || { echo "integration_test_setup.sh not found!" >&2; exit 1; } +function set_up() { + write_default_bazelrc +} + function test_glob_local_repository_dangling_symlink() { create_new_workspace r=$TEST_TMPDIR/r rm -fr $r mkdir -p $r - create_workspace_with_default_repos $r/WORKSPACE + touch $r/REPO.bazel cat > $r/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < BUILD < $TEST_log || fail "Building //:mfg failed" @@ -83,8 +86,8 @@ EOF cd ${WORKSPACE_DIR} mkdir -p {zoo,red} - cat >> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < zoo/dumper.sh <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $external_ws/greet_lib.h <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $clib/include/clib.h <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) < WORKSPACE <& $TEST_log || fail "query failed" + bazel fetch --enable_workspace --repo=@@my_repo || fail "Fetch failed" + bazel query --enable_workspace 'deps(//external:my_repo)' >& $TEST_log || fail "query failed" expect_log "//external:my_repo" } function test_repository_package_query() { mkdir a b b/b - cat > WORKSPACE < MODULE.bazel < a/BUILD - create_workspace_with_default_repos b/WORKSPACE + touch b/REPO.bazel echo "sh_library(name='b')" > b/b/BUILD bazel query --output package "deps(//a)" >& $TEST_log || fail "query failed" expect_log "a" @@ -437,12 +440,12 @@ EOF function test_repository_buildfiles_package_query() { mkdir a b b/b b/c - cat > WORKSPACE < MODULE.bazel < a/BUILD - touch b/WORKSPACE b/c/BUILD + touch b/REPO.bazel b/c/BUILD cat > b/b/BUILD < "$bar/WORKSPACE" <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <WORKSPACE <WORKSPACE <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < mutant.BUILD < $TEST_log || fail "First build failed" - assert_contains "Leonardo" bazel-genfiles/external/mutant/tmnt + bazel fetch @mutant//:turtle || fail "Fetch failed" + bazel build @mutant//:turtle &> $TEST_log || fail "First build failed" + assert_contains "Leonardo" bazel-genfiles/external/+_repo_rules+mutant/tmnt cat > mutant.BUILD < $TEST_log || fail "Second build failed" - assert_contains "Donatello" bazel-genfiles/external/mutant/tmnt + bazel build @mutant//:turtle &> $TEST_log || fail "Second build failed" + assert_contains "Donatello" bazel-genfiles/external/+_repo_rules+mutant/tmnt } function test_external_deps_in_remote_repo() { local r=$TEST_TMPDIR/r rm -fr $r mkdir -p $r - create_workspace_with_default_repos $r/WORKSPACE - cat >> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/BUILD < $r/a/BUILD <<'EOF' @@ -656,8 +651,8 @@ genrule( ) EOF - cat >> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/BUILD <<'EOF' genrule( name="r", @@ -736,8 +731,8 @@ genrule( visibility=["//visibility:public"]) EOF - cat >> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $other_ws/a/b < $other_ws/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> WORKSPACE < $r/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/bin/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/a/x/BUILD echo 'exports_files(["m", "n"])' > $r/a/y/z/BUILD - echo "local_repository(name='r', path='$r')" > WORKSPACE + cat > MODULE.bazel <& $TEST_log || fail "query failed" expect_log "@r//a/x:m" expect_log "@r//a/x:n" @@ -983,7 +982,7 @@ function test_package_name_constants() { local r=$TEST_TMPDIR/r rm -fr $r mkdir -p $r/a - create_workspace_with_default_repos $r/WORKSPACE + touch $r/REPO.bazel cat > $r/a/BUILD <<'EOF' genrule( name = 'b', @@ -992,14 +991,14 @@ genrule( cmd = 'echo ' + repository_name() + ' ' + package_name() + ' > $@') EOF - cat >> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $TEST_log - expect_log "@r a" + cat bazel-genfiles/external/+_repo_rules+r/a/bo > $TEST_log + expect_log "@+_repo_rules+r a" } function test_slash_in_repo_name() { @@ -1007,7 +1006,7 @@ function test_slash_in_repo_name() { rm -fr $r mkdir -p $r/a - create_workspace_with_default_repos $r/a/WORKSPACE + touch $r/a/REPO.bazel cat > $r/a/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $TEST_log && fail "expected build failure, but succeeded" - expect_log "repo names may contain only A-Z, a-z, 0-9, '-', '_', '.' and '+'" + expect_log "valid names may contain only A-Z, a-z, 0-9, '-', '_', '.', and must start with a letter" } function test_remote_includes() { @@ -1035,7 +1034,7 @@ function test_remote_includes() { rm -fr $remote mkdir -p $remote/inc - create_workspace_with_default_repos $remote/WORKSPACE + touch $remote/REPO.bazel cat > $remote/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $r/BUILD <<'EOF' genrule( name = "dummy1", @@ -1128,8 +1127,8 @@ genrule( ) EOF - cat >> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $TEST_log || fail "Build failed unexpectedly" expect_not_log "No MODULE.bazel, REPO.bazel, or WORKSPACE file found" } @@ -1196,7 +1195,7 @@ function test_overwrite_build_file() { local r=$TEST_TMPDIR/r rm -rf $r mkdir -p $r - create_workspace_with_default_repos $r/WORKSPACE + touch $r/REPO.bazel cat > $r/BUILD <<'EOF' genrule( name = "orig", @@ -1205,8 +1204,8 @@ genrule( ) EOF - cat >> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < $external_dir/x/X.java <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < green/BUILD <> $(create_workspace_with_default_repos WORKSPACE) <> MODULE.bazel < green/BUILD <