From 7330c2c606866976dc92bc23529f0f89c67410f1 Mon Sep 17 00:00:00 2001 From: Sylvie <35663410+Rangi42@users.noreply.github.com> Date: Sat, 31 Aug 2024 00:10:44 -0400 Subject: [PATCH] Replace `unmangle` with `cygpath` (#1490) Use `-m` not `-w` so paths use forward slashes --- .github/workflows/testing.yml | 3 +-- Makefile | 9 +++------ test/CMakeLists.txt | 6 ------ test/link/.gitignore | 2 -- test/link/test.sh | 13 ++++++------- test/link/unmangle.cpp | 16 ---------------- 6 files changed, 10 insertions(+), 39 deletions(-) delete mode 100644 test/link/.gitignore delete mode 100644 test/link/unmangle.cpp diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index cfb70c67..e9900767 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -263,7 +263,6 @@ jobs: path: | test/gfx/randtilegen.exe test/gfx/rgbgfx_test.exe - test/link/unmangle.exe windows-mingw-testing: needs: windows-mingw-build @@ -284,7 +283,7 @@ jobs: uses: actions/download-artifact@v4 with: name: testing-programs-mingw-win${{ matrix.bits }} - path: test + path: test/gfx - name: Extract binaries shell: bash run: | diff --git a/Makefile b/Makefile index 2e07a036..0afec434 100644 --- a/Makefile +++ b/Makefile @@ -130,9 +130,6 @@ test/gfx/randtilegen: test/gfx/randtilegen.cpp test/gfx/rgbgfx_test: test/gfx/rgbgfx_test.cpp $Q${CXX} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ $^ ${REALCXXFLAGS} ${PNGCFLAGS} ${PNGLDLIBS} -test/link/unmangle: test/link/unmangle.cpp - $Q${CXX} ${REALLDFLAGS} -o $@ $^ ${REALCXXFLAGS} - # Rules to process files # We want the Bison invocation to pass through our rules, not default ones @@ -180,7 +177,7 @@ clean: $Q${RM} rgbshim.sh $Q${RM} src/asm/parser.cpp src/asm/parser.hpp src/asm/stack.hh $Q${RM} src/link/script.cpp src/link/script.hpp src/link/stack.hh - $Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test test/link/unmangle + $Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test # Target used to install the binaries and man pages. @@ -251,13 +248,13 @@ iwyu: # install instructions instead. mingw32: - $Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test test/link/unmangle \ + $Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test \ CXX=i686-w64-mingw32-g++ \ CXXFLAGS="-O3 -flto -DNDEBUG -static-libgcc -static-libstdc++" \ PKG_CONFIG="PKG_CONFIG_SYSROOT_DIR=/usr/i686-w64-mingw32 pkg-config" mingw64: - $Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test test/link/unmangle \ + $Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test \ CXX=x86_64-w64-mingw32-g++ \ PKG_CONFIG="PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32 pkg-config" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e5a4a26f..b7fa0d8f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,18 +2,12 @@ add_executable(randtilegen gfx/randtilegen.cpp) add_executable(rgbgfx_test gfx/rgbgfx_test.cpp) -add_executable(unmangle link/unmangle.cpp) install(TARGETS randtilegen rgbgfx_test DESTINATION ${rgbds_SOURCE_DIR}/test/gfx COMPONENT "Test support programs" EXCLUDE_FROM_ALL ) -install(TARGETS unmangle - DESTINATION ${rgbds_SOURCE_DIR}/test/link - COMPONENT "Test support programs" - EXCLUDE_FROM_ALL - ) foreach(TARGET randtilegen rgbgfx_test) if(LIBPNG_FOUND) # pkg-config diff --git a/test/link/.gitignore b/test/link/.gitignore deleted file mode 100644 index f3cad6fa..00000000 --- a/test/link/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Test binaries -/unmangle diff --git a/test/link/test.sh b/test/link/test.sh index c66343f4..95b8f26b 100755 --- a/test/link/test.sh +++ b/test/link/test.sh @@ -3,8 +3,6 @@ export LC_ALL=C set -o pipefail -[[ -e ./unmangle ]] || make -C ../.. test/link/unmangle || exit - otemp="$(mktemp)" gbtemp="$(mktemp)" gbtemp2="$(mktemp)" @@ -88,13 +86,14 @@ evaluateTest () { } substPath () { - # Escape regex metacharacters + # Replace the file name with a different one to match changed output, escaping regex metacharacters subst="$(printf '%s\n' "$1" | sed 's:[][\/.^$*]:\\&:g')" - # Replace the file name with a different one to match changed output - sed -i'' -e "s|$subst|$2|g" "$3" - # Escape regex metacharacters in the un-MinGW-mangled path - subst="$(./unmangle "$1" | sed 's:[][\/.^$*]:\\&:g')" sed -i'' -e "s|$subst|$2|g" "$3" + if which cygpath &>/dev/null; then + # Replace the MinGW path with a Windows path, escaping regex metacharacters + subst="$(cygpath -m "$1" | sed 's:[][\/.^$*]:\\&:g')" + sed -i'' -e "s|$subst|$2|g" "$3" + fi } for i in *.asm; do diff --git a/test/link/unmangle.cpp b/test/link/unmangle.cpp deleted file mode 100644 index b501933b..00000000 --- a/test/link/unmangle.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include - -/** - * MinGW mangles path names before passing them as command-line arguments. - * Some RGBLINK warning/error messages include those mangled paths on Windows. - * We need to see those mangled paths in test.sh to replace them with placeholders. - * This tool simply echoes each argument, which will be mangled iff they are paths. - * (For example, the "/tmp/foo" will be unmangled to something like - * "C:/Users/RUNNER~1/AppData/Local/Temp/foo".) - */ - -int main(int argc, char *argv[]) { - for (int i = 1; i < argc; i++) - puts(argv[i]); - return 0; -}