From 5df1f708ad1bbc0323e579d58ee678330679bf71 Mon Sep 17 00:00:00 2001 From: Remi Thebault Date: Sat, 27 May 2023 01:46:00 +0200 Subject: [PATCH] Fix failure of test suite on POSIX failure due to change of escaping of posix paths in phobos --- test/4-describe-data-2-dmd.sh | 32 ++++++++++++++++------------ test/4-describe-data-3-zero-delim.sh | 5 ++++- test/4-describe-data-check-escape | 19 +++++++++++++++++ 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 test/4-describe-data-check-escape diff --git a/test/4-describe-data-2-dmd.sh b/test/4-describe-data-2-dmd.sh index 7d994dc28..46e25f76d 100755 --- a/test/4-describe-data-2-dmd.sh +++ b/test/4-describe-data-2-dmd.sh @@ -34,8 +34,12 @@ fi # Create the expected output path file to compare against. expected_file="$CURR_DIR/expected-describe-data-2-dmd-output" + +# check if escaping is required +. "$CURR_DIR/4-describe-data-check-escape" + # --data=main-source-file -echo -n "'$CURR_DIR/describe-project/src/dummy.d' " > "$expected_file" +echo -n "$(escaped "$CURR_DIR/describe-project/src/dummy.d") " > "$expected_file" # --data=dflags echo -n "--some-dflag " >> "$expected_file" echo -n "--another-dflag " >> "$expected_file" @@ -46,12 +50,12 @@ echo -n "-L--another-lflag " >> "$expected_file" echo -n "-L-lsomelib " >> "$expected_file" echo -n "-L-lanotherlib " >> "$expected_file" # --data=linker-files -echo -n "'$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a' " >> "$expected_file" -echo -n "'$CURR_DIR/describe-project/some.a' " >> "$expected_file" -echo -n "'$CURR_DIR/describe-dependency-1/dep.a' " >> "$expected_file" +echo -n "$(escaped "$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a") " >> "$expected_file" +echo -n "$(escaped "$CURR_DIR/describe-project/some.a") " >> "$expected_file" +echo -n "$(escaped "$CURR_DIR/describe-dependency-1/dep.a") " >> "$expected_file" # --data=source-files -echo -n "'$CURR_DIR/describe-project/src/dummy.d' " >> "$expected_file" -echo -n "'$CURR_DIR/describe-dependency-1/source/dummy.d' " >> "$expected_file" +echo -n "$(escaped "$CURR_DIR/describe-project/src/dummy.d") " >> "$expected_file" +echo -n "$(escaped "$CURR_DIR/describe-dependency-1/source/dummy.d") " >> "$expected_file" # --data=versions echo -n "-version=someVerIdent " >> "$expected_file" echo -n "-version=anotherVerIdent " >> "$expected_file" @@ -60,16 +64,16 @@ echo -n "-version=Have_describe_dependency_3 " >> "$expected_file" echo -n "-debug=someDebugVerIdent " >> "$expected_file" echo -n "-debug=anotherDebugVerIdent " >> "$expected_file" # --data=import-paths -echo -n "'-I$CURR_DIR/describe-project/src/' " >> "$expected_file" -echo -n "'-I$CURR_DIR/describe-dependency-1/source/' " >> "$expected_file" -echo -n "'-I$CURR_DIR/describe-dependency-2/some-path/' " >> "$expected_file" -echo -n "'-I$CURR_DIR/describe-dependency-3/dep3-source/' " >> "$expected_file" +echo -n "$(escaped "-I$CURR_DIR/describe-project/src/") " >> "$expected_file" +echo -n "$(escaped "-I$CURR_DIR/describe-dependency-1/source/") " >> "$expected_file" +echo -n "$(escaped "-I$CURR_DIR/describe-dependency-2/some-path/") " >> "$expected_file" +echo -n "$(escaped "-I$CURR_DIR/describe-dependency-3/dep3-source/") " >> "$expected_file" # --data=string-import-paths -echo -n "'-J$CURR_DIR/describe-project/views/' " >> "$expected_file" -echo -n "'-J$CURR_DIR/describe-dependency-2/some-extra-string-import-path/' " >> "$expected_file" -echo -n "'-J$CURR_DIR/describe-dependency-3/dep3-string-import-path/' " >> "$expected_file" +echo -n "$(escaped "-J$CURR_DIR/describe-project/views/") " >> "$expected_file" +echo -n "$(escaped "-J$CURR_DIR/describe-dependency-2/some-extra-string-import-path/") " >> "$expected_file" +echo -n "$(escaped "-J$CURR_DIR/describe-dependency-3/dep3-string-import-path/") " >> "$expected_file" # --data=import-files -echo -n "'$CURR_DIR/describe-dependency-2/some-path/dummy.d' " >> "$expected_file" +echo -n "$(escaped "$CURR_DIR/describe-dependency-2/some-path/dummy.d") " >> "$expected_file" # --data=options echo -n "-debug " >> "$expected_file" # releaseMode is not included, even though it's specified, because the requireContracts requirement drops it diff --git a/test/4-describe-data-3-zero-delim.sh b/test/4-describe-data-3-zero-delim.sh index 0a628bd86..e36aeb36e 100755 --- a/test/4-describe-data-3-zero-delim.sh +++ b/test/4-describe-data-3-zero-delim.sh @@ -111,6 +111,9 @@ if ! diff -b -B "$temp_file_normal" "$temp_file_zero_delim"; then die $LINENO 'The null-delimited dmd-style --data=versions did not match the expected output!' fi +# check if escaping is required +. "$CURR_DIR/4-describe-data-check-escape" + # Test dmd-style --data=source-files if ! $DUB describe --compiler=$DC --data=source-files \ > "$temp_file_normal"; then @@ -118,7 +121,7 @@ if ! $DUB describe --compiler=$DC --data=source-files \ fi if ! $DUB describe --compiler=$DC --data-0 --data=source-files \ - | xargs -0 printf "'%s' " > "$temp_file_zero_delim"; then + | xargs -0 printf "$(escaped "%s") " > "$temp_file_zero_delim"; then die $LINENO 'Printing null-delimited dmd-style --data=source-files failed!' fi diff --git a/test/4-describe-data-check-escape b/test/4-describe-data-check-escape new file mode 100644 index 000000000..8f3794723 --- /dev/null +++ b/test/4-describe-data-check-escape @@ -0,0 +1,19 @@ +dmd_ver=$($DC --version | grep -Eo "v2\.[0-9][0-9][0-9].[0-9]") +dmd_minor=$(echo $dmd_ver | grep -Eo "[0-9][0-9][0-9]") +dmd_micro=${dmd_ver: -1} + +if [[ $dmd_minor$dmd_micro < 1022 || "$CURR_DIR" =~ [[:space:]] ]]; then + echo "Expecting escaped paths" + escape=1 +else + echo "Not expecting escaped paths" + escape=0 +fi + +function escaped { + if [ $escape -eq 1 ]; then + echo -n "'$1'" + else + echo -n "$1" + fi +}