From: Nathan Moinvaziri Date: Sat, 19 Sep 2020 01:04:30 +0000 (-0700) Subject: Cleanup temporary files before fatal error in test-compress cmake script. X-Git-Tag: 1.9.9-b1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad2a244234f8b218b033f66353f8050c96ce6fe2;p=thirdparty%2Fzlib-ng.git Cleanup temporary files before fatal error in test-compress cmake script. --- diff --git a/cmake/test-compress.cmake b/cmake/test-compress.cmake index 26155cd6..d2a7f33e 100644 --- a/cmake/test-compress.cmake +++ b/cmake/test-compress.cmake @@ -28,6 +28,13 @@ if(NOT OUTPUT) endif() string(REPLACE ".gz" "" OUTPUT "${OUTPUT}") +macro(cleanup) + # Cleanup temporary mingizip files + file(REMOVE ${OUTPUT}.gz ${OUTPUT}.out) + # Cleanup temporary gzip files + file(REMOVE ${OUTPUT}.gzip.gz ${OUTPUT}.gzip.out) +endmacro() + # Compress input file set(COMPRESS_COMMAND ${COMPRESS_TARGET} ${COMPRESS_ARGS}) @@ -40,6 +47,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Compress failed: ${CMD_RESULT}") endif() @@ -55,6 +63,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Decompress failed: ${CMD_RESULT}") endif() @@ -64,6 +73,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Compare minigzip decompress failed: ${CMD_RESULT}") endif() @@ -83,6 +93,7 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Gzip decompress failed: ${CMD_RESULT}") endif() @@ -92,6 +103,7 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Compare gzip decompress failed: ${CMD_RESULT}") endif() @@ -107,6 +119,7 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Gzip compress failed: ${CMD_RESULT}") endif() @@ -120,6 +133,7 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Minigzip decompress gzip failed: ${CMD_RESULT}") endif() @@ -129,13 +143,10 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) + cleanup() message(FATAL_ERROR "Compare minigzip decompress gzip failed: ${CMD_RESULT}") endif() - - # Cleanup temporary files - file(REMOVE ${OUTPUT}.gzip.gz ${OUTPUT}.gzip.out) endif() endif() -# Cleanup temporary files -file(REMOVE ${OUTPUT}.gz ${OUTPUT}.out) +cleanup() \ No newline at end of file