From 53f95ed1c4ae72a5b6d41f2c2528e04d79aa03a2 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 25 Dec 2025 23:26:46 +0100 Subject: [PATCH] fix windows tests --- .github/workflows/ci.yml | 11 +--------- .../extra/tc_ufcs_all_kinds/generate_tests.d | 22 ++++++++++++++----- tests/extra/tc_ufcs_all_kinds/run.sh | 2 +- tests/run_tests.sh | 21 +++++++++++++++++- tests/tc032/.gitignore | 1 + tests/tc032/expected1.txt | 1 - tests/tc032/run.sh | 3 ++- tests/tc033/run.sh | 4 ++-- tests/tc034/.gitignore | 1 + tests/tc034/expected1.txt | 3 --- tests/tc034/run.sh | 3 ++- tests/tc035/run.sh | 2 +- tests/tc036/run.sh | 8 +++---- tests/tc062/run.sh | 4 ++-- tests/tc_access_modifiers/run.sh | 12 +++++----- tests/tc_import_symbol_list/run.sh | 2 +- tests/tc_locate_ufcs_function/run.sh | 2 +- tests/tc_recursive_public_import/run.sh | 2 +- 18 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 tests/tc032/.gitignore delete mode 100644 tests/tc032/expected1.txt create mode 100644 tests/tc034/.gitignore delete mode 100644 tests/tc034/expected1.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbeb58e..72ec61e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,17 +103,8 @@ jobs: rdmd ./d-test-utils/test_with_package.d $LIBDPARSE_VERSION libdparse -- dub build --build=${{ matrix.build }} --config=client --arch=${{ matrix.arch }} rdmd ./d-test-utils/test_with_package.d $LIBDPARSE_VERSION libdparse -- dub build --build=${{ matrix.build }} --config=server --arch=${{ matrix.arch }} - - name: Linux Tests - if: contains(matrix.os, 'ubuntu') + - name: Tests run: | ./run_tests.sh --extra working-directory: tests shell: bash - - - name: Windows and MacOS Tests - if: contains(matrix.os, 'windows') || contains(matrix.os, 'macos') - run: | - ./run_tests.sh --extra - working-directory: tests - shell: bash - continue-on-error: true diff --git a/tests/extra/tc_ufcs_all_kinds/generate_tests.d b/tests/extra/tc_ufcs_all_kinds/generate_tests.d index e8a517a..eed99b2 100644 --- a/tests/extra/tc_ufcs_all_kinds/generate_tests.d +++ b/tests/extra/tc_ufcs_all_kinds/generate_tests.d @@ -3,8 +3,8 @@ // Then it calls all functions with every type to see which ones are accepted by // the compiler, to automatically stay up-to-date. -import std; import fs = std.file; +import std; string[] testTypes = [ "bool", @@ -129,7 +129,10 @@ int main(string[] args) fs.write("proc_test.d", code); - auto output = executeShell("$DC -verrors=0 $ERROR_STYLE -c proc_test.d").output; + version (Windows) + auto output = executeShell("%DC% -verrors=0 %ERROR_STYLE% -c proc_test.d").output; + else + auto output = executeShell("$DC -verrors=0 $ERROR_STYLE -c proc_test.d").output; size_t numErrors = 0; @@ -152,7 +155,8 @@ int main(string[] args) } } - enforce(numErrors > 1_000, "compiler didn't error as expected, need to adjust tests!"); + enforce(numErrors > 1_000, "compiler didn't error as expected, need to adjust tests!\n\nSample of compiler output:\n" + ~ output[0..min($, 1000)]); writeln("Total incompatible type combinations: ", numErrors); @@ -164,8 +168,11 @@ int main(string[] args) ~ "\n" ~ varName ~ ".func_"; - string[] dcdClient = ["../../../bin/dcd-client"]; - if (args[1].length) + version (Windows) + string[] dcdClient = ["..\\..\\..\\bin\\dcd-client"]; + else + string[] dcdClient = ["../../../bin/dcd-client"]; + if (args.length > 1 && args[1].length) dcdClient ~= args[1]; auto proc = pipeProcess(dcdClient ~ ["-c" ~ to!string(input.length)]); @@ -178,9 +185,12 @@ int main(string[] args) size_t i = 0; foreach (line; proc.stdout.byLineCopy) { + if (line.length && line[$ - 1] == '\r') + line = line[0 .. $ - 1]; + if (i++ == 0) { - enforce(line == "identifiers"); + enforce(line == "identifiers", "Invalid DCD stdout first line: " ~ line); continue; } diff --git a/tests/extra/tc_ufcs_all_kinds/run.sh b/tests/extra/tc_ufcs_all_kinds/run.sh index d6688b2..91a93b6 100755 --- a/tests/extra/tc_ufcs_all_kinds/run.sh +++ b/tests/extra/tc_ufcs_all_kinds/run.sh @@ -21,4 +21,4 @@ fi export DC ERROR_STYLE # gdc uses language specific error message export LC_ALL=${LC_ALL:-"C.UTF-8"} -${DC} -run generate_tests.d "${1}" +${DC} -run generate_tests.d "$1" diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 1d4b62b..be480fb 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -90,6 +90,12 @@ function waitShutdown() fi } +if [ -n "$COMSPEC" ]; then + # Make sure all line endings are \n and not \crlf + shopt -s globstar + sed -i 's/\r$//' **/*.d +fi + # Make sure that the server is shut down if [[ "$REUSE_SERVER" == "1" ]]; then echo "Not shutting down existing server due to --reuse-server" @@ -129,7 +135,20 @@ for socket in $SOCKETMODES; do # supported: unix tcp for testCase in $TESTCASES $EXTRA_TESTCASES; do cd $testCase - ./run.sh "$tcp" + TESTCWD="$(pwd)" + SLASH="/" + SLASHSLASH="/" + WINDOWS=0 + if [ -n "$COMSPEC" ]; then + # is running on windows (transform /d/a/DCD/... to D:/a/DCD/...) + SLASH="\\\\" + SLASHSLASH="\\\\\\\\" + WINDOWS=1 + DRIVE="${TESTCWD:1:1}" + TESTCWD="${DRIVE^^}:${TESTCWD:2}" + fi + + env TESTCWD="$TESTCWD" SLASH="$SLASH" SLASHSLASH="$SLASHSLASH" WINDOWS="$WINDOWS" ./run.sh "$tcp" if [[ $? -eq 0 ]]; then echo -e "${YELLOW}$socket:$testCase:${NORMAL} ... ${GREEN}Pass${NORMAL}"; let pass_count=pass_count+1 diff --git a/tests/tc032/.gitignore b/tests/tc032/.gitignore new file mode 100644 index 0000000..e494f3a --- /dev/null +++ b/tests/tc032/.gitignore @@ -0,0 +1 @@ +/expected1.txt diff --git a/tests/tc032/expected1.txt b/tests/tc032/expected1.txt deleted file mode 100644 index 947e03f..0000000 --- a/tests/tc032/expected1.txt +++ /dev/null @@ -1 +0,0 @@ -/imports/std/stdio.d 0 diff --git a/tests/tc032/run.sh b/tests/tc032/run.sh index 9666ceb..65f65f5 100755 --- a/tests/tc032/run.sh +++ b/tests/tc032/run.sh @@ -1,5 +1,6 @@ set -e set -u -../../bin/dcd-client $1 file.d -l -c 15 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt +../../bin/dcd-client $1 file.d -l -c 15 > actual1.txt +printf "$(dirname "${TESTCWD}")/imports${SLASHSLASH}std${SLASHSLASH}stdio.d\t0\n" > expected1.txt diff actual1.txt expected1.txt --strip-trailing-cr diff --git a/tests/tc033/run.sh b/tests/tc033/run.sh index 48eb1e1..9543316 100755 --- a/tests/tc033/run.sh +++ b/tests/tc033/run.sh @@ -1,9 +1,9 @@ set -e set -u -../../bin/dcd-client $1 file.d -u -c22 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt +../../bin/dcd-client $1 file.d -u -c22 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual1.txt diff actual1.txt expected1.txt --strip-trailing-cr # should work on last character of identifier -../../bin/dcd-client $1 file.d -u -c24 | sed s\""$(dirname "$(pwd)")"\"\" > actual2.txt +../../bin/dcd-client $1 file.d -u -c24 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual2.txt diff actual2.txt expected1.txt --strip-trailing-cr diff --git a/tests/tc034/.gitignore b/tests/tc034/.gitignore new file mode 100644 index 0000000..e494f3a --- /dev/null +++ b/tests/tc034/.gitignore @@ -0,0 +1 @@ +/expected1.txt diff --git a/tests/tc034/expected1.txt b/tests/tc034/expected1.txt deleted file mode 100644 index 83f8772..0000000 --- a/tests/tc034/expected1.txt +++ /dev/null @@ -1,3 +0,0 @@ -/imports/object.d 22 -0 -12 diff --git a/tests/tc034/run.sh b/tests/tc034/run.sh index 23d10a1..2043669 100755 --- a/tests/tc034/run.sh +++ b/tests/tc034/run.sh @@ -1,5 +1,6 @@ set -e set -u -../../bin/dcd-client $1 file.d -u -c1 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt +../../bin/dcd-client $1 file.d -u -c1 > actual1.txt +printf "$(dirname "${TESTCWD}")/imports${SLASHSLASH}object.d\t22\n0\n12\n" > expected1.txt diff actual1.txt expected1.txt --strip-trailing-cr diff --git a/tests/tc035/run.sh b/tests/tc035/run.sh index bbc7fa0..0904ca6 100755 --- a/tests/tc035/run.sh +++ b/tests/tc035/run.sh @@ -1,5 +1,5 @@ set -e set -u -../../bin/dcd-client $1 file.d -u -c8 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt +../../bin/dcd-client $1 file.d -u -c8 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual1.txt diff actual1.txt expected1.txt --strip-trailing-cr diff --git a/tests/tc036/run.sh b/tests/tc036/run.sh index 604392e..1d8d231 100755 --- a/tests/tc036/run.sh +++ b/tests/tc036/run.sh @@ -1,18 +1,18 @@ set -e set -u -../../bin/dcd-client $1 file.d -c 15 | sed s\""$(dirname "$(pwd)")"\"\" > actual3.txt +../../bin/dcd-client $1 file.d -c 15 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual3.txt diff actual3.txt expected3.txt --strip-trailing-cr ../../bin/dcd-client $1 -I bar.d -../../bin/dcd-client $1 file.d -c 15 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt +../../bin/dcd-client $1 file.d -c 15 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual1.txt diff actual1.txt expected1.txt --strip-trailing-cr -../../bin/dcd-client $1 file.d -c 40 | sed s\""$(dirname "$(pwd)")"\"\" > actual2.txt +../../bin/dcd-client $1 file.d -c 40 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual2.txt diff actual2.txt expected2.txt --strip-trailing-cr ../../bin/dcd-client $1 -R bar.d -../../bin/dcd-client $1 file.d -c 15 | sed s\""$(dirname "$(pwd)")"\"\" > actual3.txt +../../bin/dcd-client $1 file.d -c 15 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual3.txt diff actual3.txt expected3.txt --strip-trailing-cr diff --git a/tests/tc062/run.sh b/tests/tc062/run.sh index 47f8452..4d7045a 100755 --- a/tests/tc062/run.sh +++ b/tests/tc062/run.sh @@ -1,7 +1,7 @@ set -e set -u -../../bin/dcd-client $1 -I $(pwd) +../../bin/dcd-client $1 -I "$(pwd)" echo | ../../bin/dcd-client $1 --search funcName > actual1.txt -echo -e "$(pwd)/file.d\tf\t5" > expected1.txt +printf "${TESTCWD}${SLASHSLASH}file.d\tf\t5\n" > expected1.txt diff actual1.txt expected1.txt --strip-trailing-cr diff --git a/tests/tc_access_modifiers/run.sh b/tests/tc_access_modifiers/run.sh index 1299748..ebae5ae 100755 --- a/tests/tc_access_modifiers/run.sh +++ b/tests/tc_access_modifiers/run.sh @@ -3,24 +3,24 @@ set -u rm -f actual1.txt actual2.txt actual3.txt actual0.txt -../../bin/dcd-client $1 file1.d -c 137 | sed s\""$(dirname "$(pwd)")"\"\" > actual0.txt +../../bin/dcd-client $1 file1.d -c 137 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual0.txt diff actual0.txt expected0.txt --strip-trailing-cr ../../bin/dcd-client $1 -I bar.d -../../bin/dcd-client $1 file1.d -c 137 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt +../../bin/dcd-client $1 file1.d -c 137 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual1.txt diff actual1.txt expected1.txt --strip-trailing-cr -../../bin/dcd-client $1 file1.d -c 152 | sed s\""$(dirname "$(pwd)")"\"\" > actual1_1.txt +../../bin/dcd-client $1 file1.d -c 152 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual1_1.txt diff actual1_1.txt expected1_1.txt --strip-trailing-cr -../../bin/dcd-client $1 file1.d -c 170 | sed s\""$(dirname "$(pwd)")"\"\" > actual2.txt +../../bin/dcd-client $1 file1.d -c 170 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual2.txt diff actual2.txt expected2.txt --strip-trailing-cr -../../bin/dcd-client $1 file2.d -c 83 | sed s\""$(dirname "$(pwd)")"\"\" > actual3.txt +../../bin/dcd-client $1 file2.d -c 83 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual3.txt diff actual3.txt expected3.txt --strip-trailing-cr ../../bin/dcd-client $1 -R bar.d -../../bin/dcd-client $1 file1.d -c 137 | sed s\""$(dirname "$(pwd)")"\"\" > actual0.txt +../../bin/dcd-client $1 file1.d -c 137 | sed s\""$(dirname "${TESTCWD}")"\"\" > actual0.txt diff actual0.txt expected0.txt --strip-trailing-cr diff --git a/tests/tc_import_symbol_list/run.sh b/tests/tc_import_symbol_list/run.sh index e11da68..3e03f57 100755 --- a/tests/tc_import_symbol_list/run.sh +++ b/tests/tc_import_symbol_list/run.sh @@ -2,5 +2,5 @@ set -e set -u ../../bin/dcd-client $1 file.d --extended -I"$PWD"/newpackage -c$(wc -c < file.d) > actual1.txt -echo -e "identifiers\nSomeStruct\ts\t\t$PWD/newpackage/newmodule.d 26\t\t" > expected1.txt +printf "identifiers\nSomeStruct\ts\t\t${TESTCWD}/newpackage${SLASHSLASH}newmodule.d 26\t\t\n" > expected1.txt diff actual1.txt expected1.txt --strip-trailing-cr diff --git a/tests/tc_locate_ufcs_function/run.sh b/tests/tc_locate_ufcs_function/run.sh index 11926e0..30c0e81 100755 --- a/tests/tc_locate_ufcs_function/run.sh +++ b/tests/tc_locate_ufcs_function/run.sh @@ -2,5 +2,5 @@ set -e set -u ../../bin/dcd-client $1 -c57 -l -I"$PWD"/barutils file.d > actual.txt -echo -e "$PWD/barutils/barutils.d\t22" > expected.txt +printf "${TESTCWD}/barutils${SLASHSLASH}barutils.d\t22\n" > expected.txt diff actual.txt expected.txt --strip-trailing-cr diff --git a/tests/tc_recursive_public_import/run.sh b/tests/tc_recursive_public_import/run.sh index 972c452..9891a95 100755 --- a/tests/tc_recursive_public_import/run.sh +++ b/tests/tc_recursive_public_import/run.sh @@ -4,5 +4,5 @@ set -u echo "import: $PWD/testing" ../../bin/dcd-client $1 app.d --extended -I $PWD/ -c50 > actual.txt -echo -e "identifiers\nworld\tv\tWorld world\t$PWD/testing/a.d 77\t\tWorld" > expected.txt +printf "identifiers\nworld\tv\tWorld world\t${TESTCWD}/testing${SLASHSLASH}a.d 77\t\tWorld\n" > expected.txt diff actual.txt expected.txt --strip-trailing-cr