-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cross-device rename failure (#593)
by creating the temporary file in the same directory as the file to be overwritten. Includes: Add ktxsc tests. Improve ktxsc docs. Simplify toktx-tests.cmake script. Simplify reference image generation scripts. Regen skybox_zstd.ktx2 reference with default version numbers. Run tests in Mingw build. Fix on_failure.ps1 to work for both Appveyor and GitHub Actions and to use intended curl. Workaround lack of 'x' mode in Mingw fopen. Fixes #581.
- Loading branch information
1 parent
78a3eb6
commit f020c1b
Showing
12 changed files
with
261 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
# Copyright 2022 The Khronos Group Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if ($args[0]) { $repo_root = $args[0] } else { $repo_root = "." } | ||
if ($args[1]) { $build_dir = $args[1] } else { $build_dir = "build" } | ||
|
||
# In Github Actions, this is called only when there is a failed test step. | ||
# In Appveyor we use the Phase environment variable. | ||
echo "Phase = $env:Phase" | ||
if ($env:Phase) { | ||
echo "Now uploading the failed tests" | ||
ls -Name $env:APPVEYOR_BUILD_FOLDER/tests/testimages/toktx* | ||
tar -cvf failed-tests.tar $env:APPVEYOR_BUILD_FOLDER/tests/testimages/toktx* | ||
curl --upload-file failed-tests.tar https://transfer.sh/toktx-failed-tests.tar | ||
echo "Now uploading the test log" | ||
curl --upload-file $env:APPVEYOR_BUILD_FOLDER/$env:BUILD_DIR/Testing/Temporary/LastTest.log https://transfer.sh/ktx-last-test.log | ||
if ($env:GITHUB_ACTIONS -or $env:Phase) { | ||
pushd $repo_root | ||
echo "Now uploading the failed tests" | ||
ls -Name tests/testimages/ktxsc* tests/testimages/toktx* | ||
if (tar -cvf failed-images.tar tests/testimages/ktxsc* tests/testimages/toktx*) { | ||
# N.B. In PS, "curl" is an alias for Invoke-WebRequest. Uploading a | ||
# file via that looks like a p.i.t.a so use the real curl command. | ||
curl.exe --upload-file failed-images.tar https://transfer.sh/ktx-failed-images.tar | ||
} | ||
# Even if there are no failed images and tar exits with false it creates | ||
# the output file. | ||
rm failed-images.tar | ||
|
||
echo "`r`nNow uploading the test log" | ||
curl.exe --upload-file $build_dir/Testing/Temporary/LastTest.log https://transfer.sh/ktx-last-test.log | ||
popd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# -*- tab-width: 4; -*- | ||
# vi: set sw=2 ts=4 expandtab: | ||
|
||
# Copyright 2022 Mark Callow | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# toktx share a common scapp class with ktxsc so the toktx tests suffice | ||
# for testing actual compression. | ||
|
||
add_test( NAME ktxsc-test-help | ||
COMMAND ktxsc --help | ||
) | ||
set_tests_properties( | ||
ktxsc-test-help | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "^Usage: ktxsc" | ||
) | ||
|
||
add_test( NAME ktxsc-test-version | ||
COMMAND ktxsc --version | ||
) | ||
set_tests_properties( | ||
ktxsc-test-version | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "^ktxsc v[0-9][0-9\\.]+" | ||
) | ||
|
||
# The near duplication of this and other tests below is due to a "limitation" | ||
# (i.e. a bug) in ctest which checks for neither a zero error code when a | ||
# PASS_REGULAR_EXPRESSION is specified nor a non-zero error code when a | ||
# FAIL_REGULAR_EXPRESSION is specified but only for matches to the REs. | ||
add_test( NAME ktxsc-test-foobar | ||
COMMAND ktxsc --foobar | ||
) | ||
set_tests_properties( | ||
ktxsc-test-foobar | ||
PROPERTIES | ||
WILL_FAIL TRUE | ||
FAIL_REGULAR_EXPRESSION "^Usage: ktxsc" | ||
) | ||
add_test( NAME ktxsc-test-foobar-exit-code | ||
COMMAND ktxsc --foobar | ||
) | ||
set_tests_properties( | ||
ktxsc-test-foobar-exit-code | ||
PROPERTIES | ||
WILL_FAIL TRUE | ||
) | ||
|
||
add_test( NAME ktxsc-test-many-in-one-out | ||
COMMAND ktxsc -o foo a.ktx2 b.ktx2 c.ktx2 | ||
) | ||
set_tests_properties( | ||
ktxsc-test-many-in-one-out | ||
PROPERTIES | ||
WILL_FAIL TRUE | ||
FAIL_REGULAR_EXPRESSION "^Can't use -o when there are multiple infiles." | ||
) | ||
|
||
add_test( NAME ktxsc-test-many-in-one-out-exit-code | ||
COMMAND ktxsc -o foo a.ktx2 b.ktx2 c.ktx2 | ||
) | ||
set_tests_properties( | ||
ktxsc-test-many-in-one-out-exit-code | ||
PROPERTIES | ||
WILL_FAIL TRUE | ||
) | ||
|
||
set( IMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/testimages" ) | ||
|
||
function( gencmpktx test_name reference source args inplace ) | ||
if (NOT inplace) | ||
set( workfile ktxsc.${reference} ) | ||
add_test( NAME ktxsc-cmp-${test_name} | ||
COMMAND ${BASH_EXECUTABLE} -c "$<TARGET_FILE:ktxsc> --test ${args} -o ${workfile} ${source} && diff ${reference} ${workfile} && rm ${workfile}" | ||
WORKING_DIRECTORY ${IMG_DIR} | ||
) | ||
elseif(${inplace} STREQUAL "cur-dir") | ||
set( workfile ktxsc.ip1.${reference} ) | ||
add_test( NAME ktxsc-cmp-${test_name} | ||
COMMAND ${BASH_EXECUTABLE} -c "cp ${source} ${workfile} && $<TARGET_FILE:ktxsc> --test ${args} ${workfile} && diff ${reference} ${workfile} && rm ${workfile}" | ||
WORKING_DIRECTORY ${IMG_DIR} | ||
) | ||
elseif(${inplace} STREQUAL "different-dir") | ||
set( workfile ktxsc.ip2.${reference} ) | ||
add_test( NAME ktxsc-cmp-${test_name} | ||
COMMAND ${BASH_EXECUTABLE} -c "cp ${source} ${workfile} && pushd ../.. && $<TARGET_FILE:ktxsc> --test ${args} ${IMG_DIR}/${workfile} && popd && diff ${reference} ${workfile} && rm ${workfile}" | ||
WORKING_DIRECTORY ${IMG_DIR} | ||
) | ||
endif() | ||
endfunction() | ||
|
||
gencmpktx( compress-explicit-output skybox_zstd.ktx2 skybox.ktx2 "--zcmp 5" "" "" ) | ||
gencmpktx( compress-in-place-cur-dir skybox_zstd.ktx2 skybox.ktx2 "--zcmp 5" "cur-dir" ) | ||
gencmpktx( compress-in-place-different-dir skybox_zstd.ktx2 skybox.ktx2 "--zcmp 5" "different-dir" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.