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

fix(write_source_files): fix nested directories #65

Merged
merged 14 commits into from
Apr 6, 2022
Prev Previous commit
Next Next commit
test symlinks - remove symlink fix
  • Loading branch information
jbedard committed Apr 6, 2022
commit e6fc9d0f3df6ef6bdce760e3d57355f81c7ebc2f
13 changes: 13 additions & 0 deletions e2e/write_source_files_symlinks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

bazel run //lib/tests/write_source_files:write_symlinks

# Ensure exists
[ -e lib/tests/write_source_files/symlink_test/a/test.txt ]
[ -e lib/tests/write_source_files/symlink_test/b/test.txt ]

# Exit if any symlinks
[ -L lib/tests/write_source_files/symlink_test/a/test.txt ] && exit 1
[ -L lib/tests/write_source_files/symlink_test/b/test.txt ] && exit 1
2 changes: 1 addition & 1 deletion lib/private/write_source_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ if [[ -f "$in" ]]; then
else
rm -Rf "$out"/*
mkdir -p "$out"
cp -fRL "$in"/* "$out"
cp -fR "$in"/* "$out"
chmod -R +w "$out"/*
fi
""".format(in_path = in_path, out_path = out_path))
Expand Down
3 changes: 2 additions & 1 deletion lib/tests/write_source_files/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist.js
subdir_test
subdir_test
symlink_test
23 changes: 22 additions & 1 deletion lib/tests/write_source_files/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,26 @@ genrule(
write_source_files(
name = "write_subdir",
diff_test = False,
files = {"subdir_test": ":subdir_test"},
files = {"subdir_test": ":subdir"},
)


# Generate some directories including symlinks
genrule(
name = "symlinks",
outs = ["symlink_test"],
cmd = ";".join([
"mkdir -p $@/a $@/b",
"echo 'test' > $@/a/test.txt",
"pushd $@/b",
"ln -s ../a/test.txt",
]),
)

# Write symlinks to source
# See e2e/write_source_files_symlinks
write_source_files(
name = "write_symlinks",
diff_test = False,
files = {"symlink_test": ":symlinks"},
)