Skip to content

Commit 1d5bb79

Browse files
authored
Improve reliability/readability of bin tests scripts and failure output (#2044)
* Improve reliability and readability of bin tests scripts and failure output The src/test/bin tests have been failing intermittently in the CI checks, and the problem appears to be known instability in CMake's file(DOWNLOAD) when invoked from processes in GitHub actions. The downloaded files occasionally have 0 size. This change brings the test images into the git repo rather than downloading them from https://github.com/AcademySoftwareFoundation/openexr-images at configure time. I did that way originally to avoid repo bloat, so I trimmed the list of files used by the tests, so the additional data is not that signifiant, a few Mb. This also restructures the test scripts to produce more informative output, and restructures the CI steps to make it easier to navigate the logs. Signed-off-by: Cary Phillips <cary@ilm.com> * put bin test images in dict; label tests with OpenEXR.bin Signed-off-by: Cary Phillips <cary@ilm.com> * typo Signed-off-by: Cary Phillips <cary@ilm.com> --------- Signed-off-by: Cary Phillips <cary@ilm.com>
1 parent a729f91 commit 1d5bb79

21 files changed

+392
-597
lines changed

.github/workflows/ci_steps.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,39 @@ jobs:
167167
working-directory: _build
168168
shell: bash
169169

170-
- name: Configure, Build, Test
170+
- name: Configure & Build
171171
if: inputs.msystem == ''
172172
run: |
173+
set -x
173174
cmake --version
174175
cmake ${{ env.CMAKE_ARGS }}
175176
cmake --build . --target install --config ${{ inputs.build-type }}
176-
if [ "${{ inputs.BUILD_TESTING }}" == "ON" ]; then
177-
ctest -T Test -C ${{ inputs.build-type }} --timeout 7200 --output-on-failure -VV
178-
fi
179177
working-directory: _build
180178
shell: bash
181179

182-
- name: Configure, Build, Test (msys2) # requires msys2 shell
180+
- name: Configure & Build (msys2) # requires msys2 shell
183181
if: inputs.msystem != ''
184182
run: |
183+
set -x
185184
cmake --version
186185
cmake ${{ env.CMAKE_ARGS }}
187186
cmake --build . --target install --config ${{ inputs.build-type }}
188-
if [ "${{ inputs.BUILD_TESTING }}" == "ON" ]; then
189-
ctest -T Test -C ${{ inputs.build-type }} --timeout 7200 --output-on-failure -VV
190-
fi
187+
working-directory: _build
188+
shell: msys2 {0}
189+
190+
- name: Test
191+
if: inputs.BUILD_TESTING == 'ON' && inputs.msystem == ''
192+
run: |
193+
set -x
194+
ctest -T Test -C ${{ inputs.build-type }} --timeout 7200 --output-on-failure -VV
195+
working-directory: _build
196+
shell: bash
197+
198+
- name: Test (msys2) # requires msys2 shell
199+
if: inputs.BUILD_TESTING == 'ON' && inputs.msystem != ''
200+
run: |
201+
set -x
202+
ctest -T Test -C ${{ inputs.build-type }} --timeout 7200 --output-on-failure -VV
191203
working-directory: _build
192204
shell: msys2 {0}
193205

src/test/bin/CMakeLists.txt

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,19 @@ if(BUILD_TESTING)
1111

1212
message(STATUS "adding bin tests")
1313

14-
set(OPENEXR_IMAGES_REPO "https://raw.githubusercontent.com/AcademySoftwareFoundation/openexr-images" CACHE STRING
15-
"Bin test Image repo")
16-
17-
set(OPENEXR_IMAGES_TAG "v1.0" CACHE STRING "Bin test image repo tag")
18-
19-
if ("${OPENEXR_IMAGES_TAG}" STREQUAL "")
20-
set(images_url ${OPENEXR_IMAGES_REPO})
21-
else()
22-
set(images_url ${OPENEXR_IMAGES_REPO}/${OPENEXR_IMAGES_TAG})
23-
endif()
24-
25-
set(images
26-
TestImages/GrayRampsHorizontal.exr
27-
LuminanceChroma/Garden.exr
28-
MultiResolution/ColorCodedLevels.exr
29-
MultiResolution/WavyLinesLatLong.exr
30-
MultiResolution/WavyLinesCube.exr
31-
LuminanceChroma/Flowers.exr
32-
MultiView/Adjuster.exr
33-
Chromaticities/Rec709_YC.exr
34-
Chromaticities/Rec709.exr
35-
Chromaticities/XYZ_YC.exr
36-
Chromaticities/XYZ.exr
37-
TestImages/GammaChart.exr
38-
Beachball/singlepart.0001.exr
39-
v2/LeftView/Balls.exr
40-
v2/Stereo/Trunks.exr
41-
Beachball/multipart.0001.exr
42-
)
43-
44-
foreach(image ${images})
45-
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${image})
46-
message(STATUS "Downloading ${images_url}/${image}")
47-
file(DOWNLOAD ${images_url}/${image} ${CMAKE_CURRENT_BINARY_DIR}/${image})
48-
endif()
49-
endforeach()
14+
set(TEST_IMAGE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/test_images")
5015

5116
add_test(NAME OpenEXR.bin.exrinfo
5217
COMMAND ${Python3_EXECUTABLE}
5318
${CMAKE_CURRENT_SOURCE_DIR}/test_exrinfo.py
54-
$<TARGET_FILE:exrinfo> ${CMAKE_CURRENT_BINARY_DIR} ${OPENEXR_VERSION})
19+
$<TARGET_FILE:exrinfo> ${TEST_IMAGE_DIR} ${OPENEXR_VERSION})
20+
set_tests_properties(OpenEXR.bin.exrinfo PROPERTIES LABELS "OpenEXR.bin")
5521

5622
add_test(NAME OpenEXR.bin.exrheader
5723
COMMAND ${Python3_EXECUTABLE}
5824
${CMAKE_CURRENT_SOURCE_DIR}/test_exrheader.py
59-
$<TARGET_FILE:exrheader> ${CMAKE_CURRENT_BINARY_DIR} ${OPENEXR_VERSION})
25+
$<TARGET_FILE:exrheader> ${TEST_IMAGE_DIR} ${OPENEXR_VERSION})
26+
set_tests_properties(OpenEXR.bin.exrheader PROPERTIES LABELS "OpenEXR.bin")
6027

6128
set(tests
6229
exr2aces
@@ -75,16 +42,25 @@ if(BUILD_TESTING)
7542
COMMAND ${Python3_EXECUTABLE}
7643
${CMAKE_CURRENT_SOURCE_DIR}/test_${test}.py
7744
$<TARGET_FILE:${test}> $<TARGET_FILE:exrinfo>
78-
${CMAKE_CURRENT_BINARY_DIR} ${OPENEXR_VERSION})
45+
${TEST_IMAGE_DIR} ${OPENEXR_VERSION})
46+
set_tests_properties(OpenEXR.bin.${test} PROPERTIES LABELS "OpenEXR.bin")
7947
endforeach()
8048

81-
# run exrcheck on all images
49+
# run exrcheck on test images
50+
set(images
51+
${TEST_IMAGE_DIR}/GrayRampsHorizontal.exr
52+
${TEST_IMAGE_DIR}/WavyLinesLatLong.exr
53+
${TEST_IMAGE_DIR}/WavyLinesCube.exr
54+
${TEST_IMAGE_DIR}/Flowers.exr
55+
${TEST_IMAGE_DIR}/GammaChart.exr
56+
${TEST_IMAGE_DIR}/multipart.0001.exr
57+
)
8258
add_test(NAME OpenEXR.bin.exrcheck
8359
COMMAND ${Python3_EXECUTABLE}
8460
${CMAKE_CURRENT_SOURCE_DIR}/test_exrcheck.py
8561
$<TARGET_FILE:exrcheck>
86-
${CMAKE_CURRENT_BINARY_DIR}
8762
${images})
63+
set_tests_properties(OpenEXR.bin.exrcheck PROPERTIES LABELS "OpenEXR.bin")
8864

8965
endif()
9066

src/test/bin/do_run.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) Contributors to the OpenEXR Project.
3+
4+
from subprocess import PIPE, run
5+
import sys
6+
7+
def do_run(cmd, expect_error = False, data=None):
8+
cmd_string = " ".join(cmd)
9+
print(f"running {cmd_string}")
10+
if data:
11+
result = run (cmd, input=data, stdout=PIPE, stderr=PIPE)
12+
else:
13+
result = run (cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
14+
if expect_error:
15+
if result.returncode != 0:
16+
return result
17+
print(f"error: {cmd_string} did not fail as expected")
18+
print(f"stdout:\n{result.stdout}")
19+
print(f"stderr:\n{result.stderr}")
20+
sys.exit(1)
21+
22+
if result.returncode != 0:
23+
print(f"error: {cmd_string} failed: returncode={result.returncode}")
24+
print(f"stdout:\n{result.stdout}")
25+
print(f"stderr:\n{result.stderr}")
26+
sys.exit(1)
27+
return result

src/test/bin/test_exr2aces.py

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,40 @@
44
# Copyright (c) Contributors to the OpenEXR Project.
55

66
import sys, os, tempfile, atexit
7-
from subprocess import PIPE, run
7+
from do_run import do_run
88

9-
print(f"testing exr2aces: {sys.argv}")
9+
print(f"testing exr2aces: {' '.join(sys.argv)}")
1010

1111
exr2aces = sys.argv[1]
1212
exrinfo = sys.argv[2]
1313
image_dir = sys.argv[3]
1414
version = sys.argv[4]
1515

16+
test_images = {}
17+
test_images["GrayRampsHorizontal"] = f"{image_dir}/GrayRampsHorizontal.exr"
18+
19+
if not os.path.isfile(exr2aces) or not os.access(exr2aces, os.X_OK):
20+
print(f"error: no such file: {exr2aces}")
21+
sys.exit(1)
22+
1623
# no args = usage message, error
17-
result = run ([exr2aces], stdout=PIPE, stderr=PIPE, universal_newlines=True)
18-
print(" ".join(result.args))
19-
assert(result.returncode != 0), "\n"+result.stderr
20-
assert(result.stderr.startswith ("Usage: ")), "\n"+result.stderr
24+
result = do_run ([exr2aces], True)
25+
assert result.stderr.startswith ("Usage: ")
2126

2227
# -h = usage message
23-
result = run ([exr2aces, "-h"], stdout=PIPE, stderr=PIPE, universal_newlines=True)
24-
print(" ".join(result.args))
25-
assert(result.returncode == 0), "\n"+result.stderr
26-
assert(result.stdout.startswith ("Usage: ")), "\n"+result.stdout
28+
result = do_run ([exr2aces, "-h"])
29+
assert result.stdout.startswith ("Usage: ")
2730

28-
result = run ([exr2aces, "--help"], stdout=PIPE, stderr=PIPE, universal_newlines=True)
29-
print(" ".join(result.args))
30-
assert(result.returncode == 0), "\n"+result.stderr
31-
assert(result.stdout.startswith ("Usage: ")), "\n"+result.stdout
31+
result = do_run ([exr2aces, "--help"])
32+
assert result.stdout.startswith ("Usage: ")
3233

3334
# --version
34-
result = run ([exr2aces, "--version"], stdout=PIPE, stderr=PIPE, universal_newlines=True)
35-
print(" ".join(result.args))
36-
assert(result.returncode == 0), "\n"+result.stderr
37-
assert(result.stdout.startswith ("exr2aces")), "\n"+result.stdout
38-
assert(version in result.stdout), "\n"+result.stdout
35+
result = do_run ([exr2aces, "--version"])
36+
assert result.stdout.startswith ("exr2aces")
37+
assert version in result.stdout
3938

4039
# invalid arguments
41-
result = run ([exr2aces, "foo.exr", "bar.exr"], stdout=PIPE, stderr=PIPE, universal_newlines=True)
42-
print(" ".join(result.args))
43-
assert(result.returncode != 0), "\n"+result.stderr
40+
result = do_run ([exr2aces, "foo.exr", "bar.exr"], True)
4441

4542
def find_line(keyword, lines):
4643
for line in lines:
@@ -55,17 +52,12 @@ def cleanup():
5552
print(f"deleting {outimage}")
5653
atexit.register(cleanup)
5754

58-
image = f"{image_dir}/TestImages/GrayRampsHorizontal.exr"
59-
result = run ([exr2aces, "-v", image, outimage], stdout=PIPE, stderr=PIPE, universal_newlines=True)
60-
print(" ".join(result.args))
61-
assert(result.returncode == 0), "\n"+result.stderr
55+
result = do_run ([exr2aces, "-v", test_images["GrayRampsHorizontal"], outimage])
6256

63-
result = run ([exrinfo, "-v", outimage], stdout=PIPE, stderr=PIPE, universal_newlines=True)
64-
print(" ".join(result.args))
65-
assert(result.returncode == 0), "\n"+result.stderr
57+
result = do_run ([exrinfo, "-v", outimage])
6658

6759
# confirm the output has the proper chromaticities
68-
assert("chromaticities: chromaticities r[0.7347, 0.2653] g[0, 1] b[0.0001, -0.077] w[0.32168, 0.33767]" in result.stdout), "\n"+result.stdout
60+
assert "chromaticities: chromaticities r[0.7347, 0.2653] g[0, 1] b[0.0001, -0.077] w[0.32168, 0.33767]" in result.stdout
6961

7062
print("success")
7163

src/test/bin/test_exrcheck.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,25 @@
44
# Copyright (c) Contributors to the OpenEXR Project.
55

66
import sys, os
7-
from subprocess import PIPE, run
7+
from do_run import do_run
88

99
print(f"testing exrcheck: {' '.join(sys.argv)}")
1010

1111
exrcheck = sys.argv[1]
12-
image_dir = sys.argv[2]
12+
image_files = sys.argv[2:]
1313

14-
for exr_file in sys.argv[3:]:
14+
if not os.path.isfile(exrcheck) or not os.access(exrcheck, os.X_OK):
15+
print(f"error: no such file: {exrcheck}")
16+
sys.exit(1)
1517

16-
exr_path = f"{image_dir}/{exr_file}"
17-
18-
result = run ([exrcheck, exr_path], stdout=PIPE, stderr=PIPE, universal_newlines=True)
19-
print(" ".join(result.args))
20-
assert(result.returncode == 0), "\n"+result.stderr
21-
22-
result = run ([exrcheck, "-m", exr_path], stdout=PIPE, stderr=PIPE, universal_newlines=True)
23-
print(" ".join(result.args))
24-
assert(result.returncode == 0), "\n"+result.stderr
25-
26-
result = run ([exrcheck, "-t", exr_path], stdout=PIPE, stderr=PIPE, universal_newlines=True)
27-
print(" ".join(result.args))
28-
assert(result.returncode == 0), "\n"+result.stderr
29-
30-
result = run ([exrcheck, "-s", exr_path], stdout=PIPE, stderr=PIPE, universal_newlines=True)
31-
print(" ".join(result.args))
32-
assert(result.returncode == 0), "\n"+result.stderr
33-
34-
result = run ([exrcheck, "-c", exr_path], stdout=PIPE, stderr=PIPE, universal_newlines=True)
35-
print(" ".join(result.args))
36-
assert(result.returncode == 0), "\n"+result.stderr
18+
for exr_file in image_files:
3719

20+
do_run([exrcheck, exr_file])
21+
do_run([exrcheck, "-m", exr_file])
22+
do_run([exrcheck, "-t", exr_file])
23+
do_run([exrcheck, "-s", exr_file])
24+
do_run([exrcheck, "-c", exr_file])
3825

3926
print("success.")
27+
sys.exit(0)
4028

0 commit comments

Comments
 (0)