diff --git a/CMakeLists.txt b/CMakeLists.txt index 53341bf2..6e1bc810 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -588,8 +588,8 @@ if (TESTS) set_tests_properties(util_${name} PROPERTIES FAIL_REGULAR_EXPRESSION "not ok -") endforeach(t) - configure_file (test/cpp.sh.in util_test_cpp.sh @ONLY) - add_test (NAME util_test_cpp COMMAND util_test_cpp.sh) + configure_file (test/cpp.py.in util_test_cpp.py @ONLY) + add_test (NAME util_test_cpp COMMAND ${PYTHON_EXECUTABLE} util_test_cpp.py) set_property (TEST util_test_cpp APPEND PROPERTY DEPENDS util_macro) set_tests_properties(util_test_cpp PROPERTIES FAIL_REGULAR_EXPRESSION "not ok -") endif () diff --git a/test/cpp.py.in b/test/cpp.py.in new file mode 100755 index 00000000..c5ca9d9d --- /dev/null +++ b/test/cpp.py.in @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +from glob import glob +import subprocess +import os.path +import sys +import tempfile + +CPP="@CMAKE_CURRENT_BINARY_DIR@/macro" + +count=0 +ret=0 + +for src in glob(os.path.join ("@CMAKE_CURRENT_SOURCE_DIR@", "test/cpp/good/*.inc")): + basename, extension = os.path.splitext(src) + res = basename + ".res" + + cpp_out = subprocess.check_output([CPP, src]) + cpp_out = cpp_out.decode() + cpp_out = cpp_out.replace("\r", "") + with open(res, "r") as f: res_out = f.read() + + head = "ok" + if cpp_out != res_out: + head = "not ok" + ret = 1 + + + print(f"{head} - {src}") + count = count + 1 + +print(f"1..{count}") +sys.exit(ret) diff --git a/test/cpp.sh.in b/test/cpp.sh.in deleted file mode 100755 index 88bf6e3b..00000000 --- a/test/cpp.sh.in +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -CPP="@CMAKE_CURRENT_BINARY_DIR@/macro" - -count=0 -ret=0 - -for src in "@CMAKE_CURRENT_SOURCE_DIR@/test/cpp/good"/*.inc; do - res="${src%.inc}.res" - - if cmp --quiet <($CPP ${src}) <(cat ${res}); then - head="ok" - else - head="not ok" - ret=1 - fi - - echo "${head} - ${src}" - count=$((count+1)) -done - -echo "1..${count}" -exit $ret