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 failure of test suite on POSIX #2648

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think printf -- '%q' "$1" is both more correct and more portable.

else
echo -n "$1"
fi
}