From 873b661be2f171da2845f858a41fbc963762f007 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 23 Mar 2024 02:19:43 +0100 Subject: [PATCH 01/24] Enable Windows CI to investigate issues --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b711b2..480f48c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,8 +6,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: -# os: [macos-latest, ubuntu-latest, windows-latest] - os: [macos-latest, ubuntu-latest] + os: [macos-latest, ubuntu-latest, windows-latest] steps: - name: checkout uses: actions/checkout@v2 From c051ffe3fb9d3fc4bb87e1c4bc158d2ac0e3c1e0 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 23 Mar 2024 03:21:04 +0100 Subject: [PATCH 02/24] Run vcpkg directly The lukka/run-vcpkg action doesn't accept the inputs it's used with, and it fails to install zlib. It seems it needs a vcpkg.json file. For our purpose, the action looks overly complicated. Just running "vcpkg install" should be good enough for now. Binary caching can be considered later if desired. --- .github/workflows/build.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 480f48c..b67f70c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,12 +12,8 @@ jobs: uses: actions/checkout@v2 - name: install dependencies (Windows) if: ${{ runner.os == 'Windows' }} - uses: lukka/run-vcpkg@v10 - id: runvcpkg - with: - vcpkgGitCommitId: 8bb3f9e4a08a5b71ee93a6f1bcdd7a258bb48392 - vcpkgTriplet: x64-windows - vcpkgArguments: zlib + run: | + vcpkg install zlib:x64-windows - name: prepare build directory run: | cmake -E make_directory ${{runner.workspace}}/build @@ -30,7 +26,8 @@ jobs: if: ${{ runner.os == 'Windows' }} working-directory: ${{runner.workspace}}/build run: | - cmake -DCMAKE_TOOLCHAIN_FILE=${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake ${{github.workspace}} + $cmarg = "-DCMAKE_TOOLCHAIN_FILE=" + $env:VCPKG_INSTALLATION_ROOT + "\scripts\buildsystems\vcpkg.cmake" + cmake $cmarg ${{github.workspace}} - name: build working-directory: ${{runner.workspace}}/build run: | From 75d3b0ac9516c555e61e397ddbdd1f3def558010 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 23 Mar 2024 21:36:38 +0100 Subject: [PATCH 03/24] Remove unused "#include " from logging.c --- src/logging.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/logging.c b/src/logging.c index d805f59..5b65e9b 100644 --- a/src/logging.c +++ b/src/logging.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "logging.h" #include "util.h" From 6549522ce869af540dd9f69a2ff6d079ff86770d Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 23 Mar 2024 21:57:20 +0100 Subject: [PATCH 04/24] util.c: Fix headers on Windows MSVC doesn't provide unistd.h; getcwd() is defined in direct.h instead. --- src/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index af42cb3..cec1990 100644 --- a/src/util.c +++ b/src/util.c @@ -21,7 +21,6 @@ #include #include #include -#include #define NDEBUG #include @@ -29,6 +28,12 @@ #include "global.h" #include "util.h" +#ifdef _WIN32 +#include +#else +#include +#endif + // The canonical order is case insensitive, but we need a tie-breaker // to avoid ambiguity int CanonicalCmp(const char *s1, const char *s2) { From 352fe467e822f87a50e14b909ddcb0a44af8f22a Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 23 Mar 2024 22:08:35 +0100 Subject: [PATCH 05/24] platform.c: WIN32: Fix typo in O_CREAT, add headers for file constants Fixes: d50049494d76 ("Add a mkstemp() implementation for WIN32") --- src/platform.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform.c b/src/platform.c index 8a39e51..1bc6329 100644 --- a/src/platform.c +++ b/src/platform.c @@ -17,10 +17,12 @@ #include "platform.h" -#ifdef WIN32 +#ifdef _WIN32 +#include #include #include #include +#include int mkstemp(char *ntemplate) { int i, fd = -1; @@ -30,7 +32,7 @@ int mkstemp(char *ntemplate) { if (!mktemp(ntemplate)) break; - fd = open(ntemplate, O_RDWR | C_CREAT | O_EXCL, S_IREAD | S_IWRITE); + fd = open(ntemplate, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE); if (fd >= 0 || errno != EEXIST) break; From 836e4b17d37280edf3762ed6fc2d72a49079d64d Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 23 Mar 2024 23:36:01 +0100 Subject: [PATCH 06/24] util.c: Add missing semicolon in WIN32-only code Fixes: f8fcedd0e0a4 ("Split out code that moves a new zip file in place to a new utility function") --- src/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index cec1990..bc78623 100644 --- a/src/util.c +++ b/src/util.c @@ -226,7 +226,7 @@ const char *UpdateFile(const char *dest, const char *tmpfile) { "Please replace the file manually."; else return "Unable to remove destination for replacement (temporary " - "file removed)." + "file removed)."; } if (rename(tmpfile, dest)) return "The original file has already been deleted, so you must rename " From d44a4c884c756ad97113ff7c7bb0bc9b7d592086 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sun, 24 Mar 2024 01:10:37 +0100 Subject: [PATCH 07/24] Use str(n)icmp instead of str(n)casecmp on WIN32 --- src/platform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform.h b/src/platform.h index bbf0f02..5d06157 100644 --- a/src/platform.h +++ b/src/platform.h @@ -44,6 +44,8 @@ int getch(void); #define stat _stati64 #define lstat stat #define off_t off64_t +#define strcasecmp stricmp +#define strncasecmp strnicmp int mkstemp(char *ntemplate); #endif From 9d169d8608c167879451674eb99e15ddf44419ef Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sun, 24 Mar 2024 01:15:18 +0100 Subject: [PATCH 08/24] Do #include before for MSVC --- src/logging.c | 2 +- src/platform.c | 1 + src/trrntzip.c | 1 + src/util.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/logging.c b/src/logging.c index 5b65e9b..360165b 100644 --- a/src/logging.c +++ b/src/logging.c @@ -19,8 +19,8 @@ #include #include #include -#include #include +#include #include #include "logging.h" diff --git a/src/platform.c b/src/platform.c index 1bc6329..923391f 100644 --- a/src/platform.c +++ b/src/platform.c @@ -22,6 +22,7 @@ #include #include #include +#include #include int mkstemp(char *ntemplate) { diff --git a/src/trrntzip.c b/src/trrntzip.c index bbfcc4f..53e90c3 100644 --- a/src/trrntzip.c +++ b/src/trrntzip.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/src/util.c b/src/util.c index bc78623..47fcf67 100644 --- a/src/util.c +++ b/src/util.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #define NDEBUG From fe0b96720a91c529c0662553aa460bc9487c83b4 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sun, 24 Mar 2024 01:29:44 +0100 Subject: [PATCH 09/24] On WIN32, #include for getch() --- src/logging.c | 4 ++++ src/trrntzip.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/logging.c b/src/logging.c index 360165b..048a5b5 100644 --- a/src/logging.c +++ b/src/logging.c @@ -26,6 +26,10 @@ #include "logging.h" #include "util.h" +#ifdef _WIN32 +#include +#endif + static FILE *OpenLog(const char *szFileName); // Global var to store if the logprint func is expecting more diff --git a/src/trrntzip.c b/src/trrntzip.c index 53e90c3..66d7d9a 100644 --- a/src/trrntzip.c +++ b/src/trrntzip.c @@ -43,6 +43,10 @@ #include "logging.h" #include "util.h" +#ifdef _WIN32 +#include +#endif + #ifndef TZ_VERSION #error "Build system must define TZ_VERSION" #endif From 177c1c695b4edb644a980d77c88c8c49ea320c09 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sun, 24 Mar 2024 02:29:21 +0100 Subject: [PATCH 10/24] Define off64_t on WIN32 --- src/platform.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platform.h b/src/platform.h index 5d06157..ed7633f 100644 --- a/src/platform.h +++ b/src/platform.h @@ -43,6 +43,7 @@ int getch(void); #define DIRSEP '\\' #define stat _stati64 #define lstat stat +#define off64_t __int64 #define off_t off64_t #define strcasecmp stricmp #define strncasecmp strnicmp From b6cbb93d995e6e1887cd15ca01dede1b01664e4b Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sun, 24 Mar 2024 02:32:54 +0100 Subject: [PATCH 11/24] platform.c: #include "platform.h" after system headers A #define in the local header (probably "stat" or "off_t") interferes badly with sys/stat.h on WIN32. --- src/platform.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform.c b/src/platform.c index 923391f..14bcd1e 100644 --- a/src/platform.c +++ b/src/platform.c @@ -15,8 +15,6 @@ // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -#include "platform.h" - #ifdef _WIN32 #include #include @@ -25,6 +23,8 @@ #include #include +#include "platform.h" + int mkstemp(char *ntemplate) { int i, fd = -1; char *copy = strdup(ntemplate); @@ -53,6 +53,8 @@ int mkstemp(char *ntemplate) { #include #include +#include "platform.h" + #if defined(__CYGWIN__) /* Workaround for Cygwin, which is missing cfmakeraw */ /* Pasted from man page; added in serial.c arbitrarily */ From 2ce7b0aef1f1b9e98a3a74ce3b2531c85f73e17b Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sun, 24 Mar 2024 21:56:34 +0100 Subject: [PATCH 12/24] Add opendir/closedir/readdir implementation for Windows MSVC doesn't have dirent.h or the associated functions for reading a directory. Add simple wrappers around findfirst/findnext/findclose (to be exact, the *i64 variants) to provide the required functionality. These wrappers and the recursive file search code in trrntzip.c could be further improved to make use of the returned type and size information and avoid calling lstat() (some unix systems return type information, too). Also note that we should probably add configure checks for the functions instead of using _WIN32 to enable our own versions since other toolchains on Windows (e.g. cygwin) may provide a proper readdir() implementation. Fix headers on WIN32 in trrntzip.c: skip dirent.h and unistd.h and #include instead. Also remove completely unneeded utime.h while at it. --- src/platform.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/platform.h | 8 ++++++++ src/trrntzip.c | 15 ++++++++------- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/platform.c b/src/platform.c index 14bcd1e..46013da 100644 --- a/src/platform.c +++ b/src/platform.c @@ -18,6 +18,7 @@ #ifdef _WIN32 #include #include +#include #include #include #include @@ -25,6 +26,49 @@ #include "platform.h" +struct dir_s { + intptr_t handle; + int unread; + struct _finddatai64_t entry; +}; + +DIR *opendir(const char *name) { + size_t sz = strlen(name) + 3; + char *spec = malloc(sz); + DIR *dirp = malloc(sizeof(DIR)); + + if (!spec || !dirp) { + free(spec); + free(dirp); + return NULL; + } + snprintf(spec, sz, "%s%c*", name, DIRSEP); + dirp->unread = 1; + dirp->handle = _findfirsti64(spec, &dirp->entry); + free(spec); + if (dirp->handle == -1) { + free(dirp); + return NULL; + } + return dirp; +} + +int closedir(DIR *dirp) { + int rv = _findclose(dirp->handle); + free(dirp); + return rv; +} + +struct dirent *readdir(DIR *dirp) { + if (dirp->unread) { + dirp->unread = 0; + return &dirp->entry; + } + if (_findnexti64(dirp->handle, &dirp->entry)) + return NULL; + return &dirp->entry; +} + int mkstemp(char *ntemplate) { int i, fd = -1; char *copy = strdup(ntemplate); diff --git a/src/platform.h b/src/platform.h index ed7633f..11fda6c 100644 --- a/src/platform.h +++ b/src/platform.h @@ -48,6 +48,14 @@ int getch(void); #define strcasecmp stricmp #define strncasecmp strnicmp +typedef struct dir_s DIR; +#define dirent _finddatai64_t +#define d_name name + +DIR *opendir(const char *name); +int closedir(DIR *dirp); +struct dirent *readdir(DIR *dirp); + int mkstemp(char *ntemplate); #endif diff --git a/src/trrntzip.c b/src/trrntzip.c index 66d7d9a..9741d72 100644 --- a/src/trrntzip.c +++ b/src/trrntzip.c @@ -23,7 +23,6 @@ #include "minizip.h" #include -#include #include #include #include @@ -33,20 +32,22 @@ #include #include #include -#include -#include #define NDEBUG #include -#include "global.h" -#include "logging.h" -#include "util.h" - #ifdef _WIN32 #include +#include +#else +#include +#include #endif +#include "global.h" +#include "logging.h" +#include "util.h" + #ifndef TZ_VERSION #error "Build system must define TZ_VERSION" #endif From 4b19af214803acfab2f285584dbb624529b1423b Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sun, 24 Mar 2024 22:23:34 +0100 Subject: [PATCH 13/24] trrntzip.c: #define some macros if missing (on Windows) MSVC doesn't provide the following macros: * R_OK and W_OK for access(), * S_ISDIR() and S_ISREG() file type tests. --- src/trrntzip.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/trrntzip.c b/src/trrntzip.c index 9741d72..068edfc 100644 --- a/src/trrntzip.c +++ b/src/trrntzip.c @@ -48,6 +48,20 @@ #include "logging.h" #include "util.h" +// The following macros may be missing on Windows +#ifndef R_OK +#define R_OK 4 +#endif +#ifndef W_OK +#define W_OK 2 +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + #ifndef TZ_VERSION #error "Build system must define TZ_VERSION" #endif From 5c9d6d87e6fe2e0a0864d9aff286e03c9599f6c8 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Mon, 25 Mar 2024 12:51:36 +0100 Subject: [PATCH 14/24] Don't use empty initializer lists Initializing a struct with an empty initializer is a gcc extension and not accepted by MSVC. Use {0} instead, which conforms to the C standard. --- src/trrntzip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/trrntzip.c b/src/trrntzip.c index 068edfc..d3321c9 100644 --- a/src/trrntzip.c +++ b/src/trrntzip.c @@ -787,7 +787,7 @@ int RecursiveMigrateDir(const char *pszRelPath, WORKSPACE *ws) { int FileNameStartPos; DIR *dirp = NULL; - MIGRATE mig = {}; + MIGRATE mig = {0}; // Get our start time for the conversion process of this dir/zip mig.StartTime = time(NULL); @@ -903,7 +903,7 @@ int RecursiveMigrateTop(const char *pszRelPath, WORKSPACE *ws) { char szRelPathBuf[MAX_PATH + 1]; int n; struct stat istat; - MIGRATE mig = {}; + MIGRATE mig = {0}; mig.StartTime = time(NULL); From 44d18dc86dce063e576e8b7adc9b0c1fa786a933 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Mon, 25 Mar 2024 17:52:14 +0100 Subject: [PATCH 15/24] CMakeLists.txt: only link with libm on unix --- src/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d97500..768e989 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,9 @@ file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/minizip/*.c) add_executable(trrntzip ${SOURCES}) target_compile_definitions(trrntzip PRIVATE "TZ_VERSION=\"${PROJECT_VERSION}\"") -target_link_libraries(trrntzip m ZLIB::ZLIB) +target_link_libraries(trrntzip ZLIB::ZLIB) +if (UNIX) + target_link_libraries(trrntzip m) +endif() set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/minizip/unzip.c APPEND PROPERTY COMPILE_DEFINITIONS UNZ_MAXFILENAMEINZIP=1024) install(TARGETS trrntzip EXPORT ${PROJECT_NAME}-targets DESTINATION bin) From cac928410f371d136cebabc775eda8267dd9e9d7 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Mon, 25 Mar 2024 13:19:33 +0100 Subject: [PATCH 16/24] CI: update to checkout@v4 to silence node deprecation warnings --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b67f70c..907ced4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: os: [macos-latest, ubuntu-latest, windows-latest] steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: install dependencies (Windows) if: ${{ runner.os == 'Windows' }} run: | From 4db8f0f5a153899c3f16f4629d773d95822cfe46 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Mon, 25 Mar 2024 18:41:10 +0100 Subject: [PATCH 17/24] CI: merge configure steps Export an environment variable with the cmake argument that sets the vcpkg toolchain file from the step that installs zlib with vcpkg. Merge the prepare build directory/configure (Unix)/configure (Windows) steps, using the variable exported earlier; let cmake create the build directory by running it with -B and -S arguments. Capitalize step names to match style of predefined steps. --- .github/workflows/build.yml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 907ced4..1dae14e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,27 +8,18 @@ jobs: matrix: os: [macos-latest, ubuntu-latest, windows-latest] steps: - - name: checkout + - name: Checkout source uses: actions/checkout@v4 - - name: install dependencies (Windows) + - name: 'Install dependencies: zlib (Windows)' if: ${{ runner.os == 'Windows' }} run: | vcpkg install zlib:x64-windows - - name: prepare build directory + $cmtc = "CMAKE_TC_ARG=-DCMAKE_TOOLCHAIN_FILE=" + $env:VCPKG_INSTALLATION_ROOT + "\scripts\buildsystems\vcpkg.cmake" + echo $cmtc >> $env:GITHUB_ENV + - name: Configure run: | - cmake -E make_directory ${{runner.workspace}}/build - - name: configure (Unix) - if: ${{ runner.os != 'Windows' }} - working-directory: ${{runner.workspace}}/build - run: | - cmake ${{github.workspace}} - - name: configure (Windows) - if: ${{ runner.os == 'Windows' }} - working-directory: ${{runner.workspace}}/build - run: | - $cmarg = "-DCMAKE_TOOLCHAIN_FILE=" + $env:VCPKG_INSTALLATION_ROOT + "\scripts\buildsystems\vcpkg.cmake" - cmake $cmarg ${{github.workspace}} - - name: build + cmake ${{env.CMAKE_TC_ARG}} -B ${{runner.workspace}}/build -S ${{github.workspace}} + - name: Build working-directory: ${{runner.workspace}}/build run: | cmake --build . --config Release From 9bc31ecd5b9a17ce0d74926de21c9314e734c8da Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Mon, 25 Mar 2024 18:59:10 +0100 Subject: [PATCH 18/24] CI: install nihtest --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1dae14e..c2f21c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,9 @@ jobs: vcpkg install zlib:x64-windows $cmtc = "CMAKE_TC_ARG=-DCMAKE_TOOLCHAIN_FILE=" + $env:VCPKG_INSTALLATION_ROOT + "\scripts\buildsystems\vcpkg.cmake" echo $cmtc >> $env:GITHUB_ENV + - name: 'Install test dependencies: nihtest' + run: | + pip install nihtest - name: Configure run: | cmake ${{env.CMAKE_TC_ARG}} -B ${{runner.workspace}}/build -S ${{github.workspace}} From b835c74ece2715c49fdd92e85c3b8abe059463a2 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Mon, 25 Mar 2024 19:00:35 +0100 Subject: [PATCH 19/24] CI: run tests --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2f21c2..866ac85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,3 +26,7 @@ jobs: working-directory: ${{runner.workspace}}/build run: | cmake --build . --config Release + - name: Run tests + working-directory: ${{runner.workspace}}/build + run: | + ctest -C Release --output-on-failure --timeout 99 From d31fc3e314dc0f60ea4eab2f09e9e56bafaacd1a Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Tue, 26 Mar 2024 18:50:39 +0100 Subject: [PATCH 20/24] Fix nihtest's program-directories for multi-config generators Let cmake compute a path including binary dirs suffixed for each configuration type. (Didn't figure out yet how to substitute only the dir for the active config.) --- regress/CMakeLists.txt | 4 ++++ regress/nihtest.conf.in | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/regress/CMakeLists.txt b/regress/CMakeLists.txt index bafe975..9460001 100644 --- a/regress/CMakeLists.txt +++ b/regress/CMakeLists.txt @@ -14,4 +14,8 @@ if(RUN_REGRESS) endforeach() endif() +set(TEST_BINARY_PATH ${PROJECT_BINARY_DIR}/src) +foreach (cfg ${CMAKE_CONFIGURATION_TYPES}) + set(TEST_BINARY_PATH "${TEST_BINARY_PATH}\n\t${PROJECT_BINARY_DIR}/src/${cfg}") +endforeach() configure_file(nihtest.conf.in nihtest.conf @ONLY) diff --git a/regress/nihtest.conf.in b/regress/nihtest.conf.in index 52be68c..45959cf 100644 --- a/regress/nihtest.conf.in +++ b/regress/nihtest.conf.in @@ -1,6 +1,6 @@ [settings] test-input-directories = @CMAKE_CURRENT_SOURCE_DIR@ -program-directories = @PROJECT_BINARY_DIR@/src +program-directories = @TEST_BINARY_PATH@ default-program = trrntzip default-stderr-replace = "^[^ :]*: " "" From bf79eeb55f7b5931069d502fd424226acdb61abb Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Tue, 26 Mar 2024 23:54:30 +0100 Subject: [PATCH 21/24] Add -g to tests with bad zips to prevent them from hanging on Windows --- regress/cli-e-2.test | 2 +- regress/cli-e.test | 2 +- regress/longername.test | 2 +- regress/truncated.test | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/regress/cli-e-2.test b/regress/cli-e-2.test index ae85d8e..4961bd4 100644 --- a/regress/cli-e-2.test +++ b/regress/cli-e-2.test @@ -1,6 +1,6 @@ description test -e: write error log to file return 0 -arguments -e -l dupe.zip +arguments -e -l -g dupe.zip file dupe.zip dupe.zip dupe.zip stdout Rezipping - dupe.zip diff --git a/regress/cli-e.test b/regress/cli-e.test index 6e19042..4a0f7cb 100644 --- a/regress/cli-e.test +++ b/regress/cli-e.test @@ -1,6 +1,6 @@ description test -e: write error log to file return 0 -arguments -eerror.log -l dupe.zip +arguments -eerror.log -l -g dupe.zip file dupe.zip dupe.zip dupe.zip stdout Rezipping - dupe.zip diff --git a/regress/longername.test b/regress/longername.test index 519d0df..8310e54 100644 --- a/regress/longername.test +++ b/regress/longername.test @@ -1,6 +1,6 @@ description torrentzip a zip with a too long entry name return 0 -arguments -l longername.zip +arguments -l -g longername.zip file longername.zip longername.zip stderr Could not list contents of "longername.zip". File is corrupted or contains entries with bad names. diff --git a/regress/truncated.test b/regress/truncated.test index 2daef2c..1555121 100644 --- a/regress/truncated.test +++ b/regress/truncated.test @@ -1,6 +1,6 @@ description skip tiny files without attempting to open return 0 -arguments -l truncated.zip +arguments -l -g truncated.zip file truncated.zip truncated.zip stderr "truncated.zip" is too small (21 bytes). File may be corrupt. From d91041efe8c1c5fd911c9dab8b8884a1b1c98bd5 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Wed, 27 Mar 2024 11:08:55 +0100 Subject: [PATCH 22/24] Mark tests failing on Windows Four test fail because the directory separator is different on Windows; the tests need to be fixed to accept either variant. In case of directories-2-d.test, the "Directory ${dir}/ Removed" messages may appear in any order (it depends on the implementation details of qsort()). Though the test happens to work on the other major systems, it isn't valid anywhere in its current state and needs to be fixed or disabled. --- regress/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/regress/CMakeLists.txt b/regress/CMakeLists.txt index 9460001..5b94eb7 100644 --- a/regress/CMakeLists.txt +++ b/regress/CMakeLists.txt @@ -1,5 +1,14 @@ set(XFAIL_TESTS ) +if(WIN32) + set(XFAIL_TESTS ${XFAIL_TESTS} + cli-q.test + cli-s.test + directories-2-d.test + recurse.test + recursive.test + ) +endif() if(RUN_REGRESS) file(GLOB TEST_CASES ${CMAKE_CURRENT_SOURCE_DIR}/*.test) From cc781e229ac9a6f46be6c7bd0a376c00b2e357e9 Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Thu, 28 Mar 2024 16:41:23 +0100 Subject: [PATCH 23/24] CMakeLists.txt: Show found nihtest version in status message --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3447e3d..5b45e9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,8 @@ if(RUN_REGRESS) if (${NIHTEST_VERSION} VERSION_LESS ${NIHTEST_REQUIRED_VERSION}) message(WARNING "-- nihtest ${NIHTEST_VERSION} too old, at least ${NIHTEST_REQUIRED_VERSION} required, regression testing disabled") set(RUN_REGRESS OFF) + else() + message(STATUS "Found nihtest: ${NIHTEST} (found suitable version \"${NIHTEST_VERSION}\", minimum required is \"${NIHTEST_REQUIRED_VERSION}\")") endif() endif() endif() From 511a52442fd6efd9c64c210c6c4f8a3ff696458f Mon Sep 17 00:00:00 2001 From: Alexander Miller Date: Sat, 30 Mar 2024 23:39:53 +0100 Subject: [PATCH 24/24] CI: Enable vcpkg to use GitHub Actions cache --- .github/workflows/build.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 866ac85..a9cccb5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,12 +10,19 @@ jobs: steps: - name: Checkout source uses: actions/checkout@v4 + - name: 'Environment setup (Windows)' + if: ${{ runner.os == 'Windows' }} + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('CMAKE_TC_ARG', '-DCMAKE_TOOLCHAIN_FILE=' + (process.env.VCPKG_INSTALLATION_ROOT || '') + '\\scripts\\buildsystems\\vcpkg.cmake'); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite'); - name: 'Install dependencies: zlib (Windows)' if: ${{ runner.os == 'Windows' }} run: | vcpkg install zlib:x64-windows - $cmtc = "CMAKE_TC_ARG=-DCMAKE_TOOLCHAIN_FILE=" + $env:VCPKG_INSTALLATION_ROOT + "\scripts\buildsystems\vcpkg.cmake" - echo $cmtc >> $env:GITHUB_ENV - name: 'Install test dependencies: nihtest' run: | pip install nihtest