mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-02 15:54:06 +00:00
build_static_site.sh: create target if nonexistent (#695)
Summary: The current version of the build script has the safe but annoying property that the target directory must be an existing, empty directory. It seems reasonable and convenient to allow the build script to create the directory with `mkdir -p`. It still fails if the directory is not empty or is a file. Test Plan: Unit tests updated; run `yarn sharness-full`. wchargin-branch: build-mkdir-p
This commit is contained in:
parent
3216f5596e
commit
d839fcae95
@ -45,9 +45,7 @@ parse_args() {
|
||||
fi
|
||||
shift
|
||||
if [ $# -eq 0 ]; then die 'missing value for --target'; fi
|
||||
if ! target="$(readlink -e "$1")"; then
|
||||
die "target does not exist: $1"
|
||||
fi
|
||||
target="$1"
|
||||
;;
|
||||
--repo)
|
||||
shift
|
||||
@ -79,12 +77,16 @@ parse_args() {
|
||||
if [ -z "${target}" ]; then
|
||||
die 'target directory not specified'
|
||||
fi
|
||||
if ! [ -e "${target}" ]; then
|
||||
mkdir -p -- "${target}"
|
||||
fi
|
||||
if ! [ -d "${target}" ]; then
|
||||
die "target is not a directory: ${target}"
|
||||
fi
|
||||
if [ "$(command ls -A "${target}" | wc -l)" != 0 ]; then
|
||||
die "target directory is nonempty: ${target}"
|
||||
fi
|
||||
target="$(readlink -e "${target}")"
|
||||
}
|
||||
|
||||
build() {
|
||||
|
@ -48,21 +48,17 @@ test_expect_success "should fail with multiple targets" '
|
||||
grep -qF -- "--target specified multiple times" err
|
||||
'
|
||||
|
||||
test_expect_success "should fail with nonexistent targets" '
|
||||
test_must_fail run --target wat 2>err &&
|
||||
grep -qF -- "target does not exist: wat" err
|
||||
'
|
||||
|
||||
test_expect_success "should fail with nonexistent targets with subcomponents" '
|
||||
# using "readlink -f", this behavior can be different.
|
||||
test_must_fail run --target wat/wat 2>err &&
|
||||
grep -qF -- "target does not exist: wat/wat" err
|
||||
'
|
||||
|
||||
test_expect_success "should fail with a file as target" '
|
||||
printf "important\nstuff" >important_data &&
|
||||
test_must_fail run --target important_data 2>err &&
|
||||
grep -qF -- "target is not a directory: ${PWD}/important_data" err &&
|
||||
grep -qF -- "target is not a directory" err &&
|
||||
printf "important\nstuff" | test_cmp - important_data
|
||||
'
|
||||
|
||||
test_expect_success "should fail with a target under a file" '
|
||||
printf "important\nstuff" >important_data &&
|
||||
test_must_fail run --target important_data/something 2>err &&
|
||||
grep -q -- "cannot create directory.*Not a directory" err &&
|
||||
printf "important\nstuff" | test_cmp - important_data
|
||||
'
|
||||
|
||||
@ -70,7 +66,7 @@ test_expect_success "should fail with a nonempty directory as target" '
|
||||
mkdir important_dir &&
|
||||
printf "redacted\n" >important_dir/.wallet.dat &&
|
||||
test_must_fail run --target important_dir 2>err &&
|
||||
grep -qF -- "target directory is nonempty: ${PWD}/important_dir" err &&
|
||||
grep -qF -- "target directory is nonempty: important_dir" err &&
|
||||
printf "redacted\n" | test_cmp - important_dir/.wallet.dat
|
||||
'
|
||||
|
||||
@ -116,7 +112,7 @@ fi
|
||||
run_build() {
|
||||
prereq_name="$1"; shift
|
||||
description="$1"; shift
|
||||
output_dir="output_${prereq_name}"
|
||||
output_dir="build_output/output_${prereq_name}"
|
||||
api_dir="${output_dir}/api/v1/data"
|
||||
data_dir="${api_dir}/data"
|
||||
for arg in "${output_dir}" "$@"; do
|
||||
@ -129,7 +125,6 @@ run_build() {
|
||||
flags="--target $output_dir $*" # checked for sanity above
|
||||
test_expect_success EXPENSIVE,HAVE_GITHUB_TOKEN \
|
||||
"${prereq_name}: ${description}" '
|
||||
mkdir "${output_dir}" &&
|
||||
run '"${flags}"' 2>err &&
|
||||
test_must_fail grep -vF \
|
||||
-e "Removing build directory: " \
|
||||
|
Loading…
x
Reference in New Issue
Block a user