Skip to content

Commit

Permalink
Fix failure of test suite on POSIX
Browse files Browse the repository at this point in the history
failure due to change of escaping of posix paths in phobos
  • Loading branch information
rtbo authored and WebFreak001 committed Jul 20, 2023
1 parent 90fc0d1 commit 3cc17fc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
32 changes: 18 additions & 14 deletions test/4-describe-data-2-dmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/4-describe-data-3-zero-delim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ 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
die $LINENO 'Printing dmd-style --data=source-files failed!'
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

Expand Down
19 changes: 19 additions & 0 deletions test/4-describe-data-check-escape
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 3cc17fc

Please sign in to comment.