Loading bp2build/symlink_forest.go +10 −4 Original line number Diff line number Diff line Loading @@ -95,13 +95,19 @@ func isDir(path string, fi os.FileInfo) bool { return fi.IsDir() } fi2, err := os.Stat(path) if err != nil { fmt.Fprintf(os.Stderr, "Cannot stat '%s': %s\n", path, err) fi2, statErr := os.Stat(path) if statErr == nil { return fi2.IsDir() } // Check if this is a dangling symlink. If so, treat it like a file, not a dir. _, lstatErr := os.Lstat(path) if lstatErr != nil { fmt.Fprintf(os.Stderr, "Cannot stat or lstat '%s': %s\n%s\n", path, statErr, lstatErr) os.Exit(1) } return fi2.IsDir() return false } // Recursively plants a symlink forest at forestDir. The symlink tree will Loading tests/bp2build_bazel_test.sh +26 −0 Original line number Diff line number Diff line Loading @@ -169,3 +169,29 @@ EOF } test_cc_correctness # Regression test for the following failure during symlink forest creation: # # Cannot stat '/tmp/st.rr054/foo/bar/unresolved_symlink': stat /tmp/st.rr054/foo/bar/unresolved_symlink: no such file or directory # function test_bp2build_null_build_with_unresolved_symlink_in_source() { setup mkdir -p foo/bar ln -s /tmp/non-existent foo/bar/unresolved_symlink cat > foo/bar/Android.bp <<'EOF' filegroup { name: "fg", srcs: ["unresolved_symlink/non-existent-file.txt"], } EOF run_soong bp2build dest=$(readlink -f out/soong/workspace/foo/bar/unresolved_symlink) if [[ "$dest" != "/tmp/non-existent" ]]; then fail "expected to plant an unresolved symlink out/soong/workspace/foo/bar/unresolved_symlink that resolves to /tmp/non-existent" fi } test_bp2build_null_build_with_unresolved_symlink_in_source tests/lib.sh +4 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,10 @@ function create_mock_bazel() { } run_bazel() { # Remove the ninja_build output marker file to communicate to buildbot that this is not a regular Ninja build, and its # output should not be parsed as such. rm -rf out/ninja_build tools/bazel "$@" } Loading Loading
bp2build/symlink_forest.go +10 −4 Original line number Diff line number Diff line Loading @@ -95,13 +95,19 @@ func isDir(path string, fi os.FileInfo) bool { return fi.IsDir() } fi2, err := os.Stat(path) if err != nil { fmt.Fprintf(os.Stderr, "Cannot stat '%s': %s\n", path, err) fi2, statErr := os.Stat(path) if statErr == nil { return fi2.IsDir() } // Check if this is a dangling symlink. If so, treat it like a file, not a dir. _, lstatErr := os.Lstat(path) if lstatErr != nil { fmt.Fprintf(os.Stderr, "Cannot stat or lstat '%s': %s\n%s\n", path, statErr, lstatErr) os.Exit(1) } return fi2.IsDir() return false } // Recursively plants a symlink forest at forestDir. The symlink tree will Loading
tests/bp2build_bazel_test.sh +26 −0 Original line number Diff line number Diff line Loading @@ -169,3 +169,29 @@ EOF } test_cc_correctness # Regression test for the following failure during symlink forest creation: # # Cannot stat '/tmp/st.rr054/foo/bar/unresolved_symlink': stat /tmp/st.rr054/foo/bar/unresolved_symlink: no such file or directory # function test_bp2build_null_build_with_unresolved_symlink_in_source() { setup mkdir -p foo/bar ln -s /tmp/non-existent foo/bar/unresolved_symlink cat > foo/bar/Android.bp <<'EOF' filegroup { name: "fg", srcs: ["unresolved_symlink/non-existent-file.txt"], } EOF run_soong bp2build dest=$(readlink -f out/soong/workspace/foo/bar/unresolved_symlink) if [[ "$dest" != "/tmp/non-existent" ]]; then fail "expected to plant an unresolved symlink out/soong/workspace/foo/bar/unresolved_symlink that resolves to /tmp/non-existent" fi } test_bp2build_null_build_with_unresolved_symlink_in_source
tests/lib.sh +4 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,10 @@ function create_mock_bazel() { } run_bazel() { # Remove the ninja_build output marker file to communicate to buildbot that this is not a regular Ninja build, and its # output should not be parsed as such. rm -rf out/ninja_build tools/bazel "$@" } Loading