fix(write_source_files): fix nested directories (#65)

This commit is contained in:
Jason Bedard 2022-04-06 11:25:17 -07:00 committed by GitHub
parent 35b8fd3425
commit 0f30bf96b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 4 deletions

View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
bazel run //lib/tests/write_source_files:write_subdir
[ -e lib/tests/write_source_files/subdir_test/a/b/c/test.txt ]
bazel run //lib/tests/write_source_files:write_subdir
[ -e lib/tests/write_source_files/subdir_test/a/b/c/test.txt ]

View File

@ -0,0 +1,18 @@
#!/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
if [ -L lib/tests/write_source_files/symlink_test/a/test.txt ]; then
exit 1
fi
if [ -L lib/tests/write_source_files/symlink_test/b/test.txt ]; then
exit 1
fi

View File

@ -164,11 +164,12 @@ echo "Copying $in to $out in $PWD"
if [[ -f "$in" ]]; then
cp -f "$in" "$out"
chmod 664 "$out"
chmod ug+w "$out"
else
rm -Rf "$out"/*
mkdir -p "$out"
cp -fR "$in"/* "$out"
chmod 664 "$out"/*
cp -fRL "$in"/* "$out"
chmod -R ug+w "$out"/*
fi
""".format(in_path = in_path, out_path = out_path))

View File

@ -1 +1,3 @@
dist.js
dist.js
subdir_test
symlink_test

View File

@ -127,8 +127,49 @@ genrule(
)
# ibazel run //lib/tests/write_source_files:write_dist
# See e2e/write_source_files_gitignored
write_source_files(
name = "write_dist",
diff_test = False,
files = {"dist.js": ":dist"},
)
# Generate a readonly file in nested readonly directories
genrule(
name = "subdir",
outs = ["subdir_test"],
cmd = ";".join([
"mkdir -p $@/a/b/c",
"echo 'test' > $@/a/b/c/test.txt",
"chmod -R -w $@/*"
]),
)
# Write nested subdirectories to source
# See e2e/write_source_files_subdir_multiple_runs
write_source_files(
name = "write_subdir",
diff_test = False,
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"},
)