diff --git a/CMakeLists.txt b/CMakeLists.txt index a42ba8d..2798b6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -447,3 +447,17 @@ if(ARITH_ENABLED) else() message(STATUS "Arithmetic Coding: Disabled") endif() + + + +find_package(Python3 COMPONENTS Interpreter Development) + +if (Python3_FOUND) + enable_testing() + add_test(NAME unittests + COMMAND ${Python3_EXECUTABLE} test.py + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test + ) + + set_property(TEST unittests PROPERTY ENVIRONMENT "JPEGOPTIM=$") +endif() diff --git a/test/jpegoptim_test2.jpg b/test/jpegoptim_test2.jpg index c629711..ee0a3fd 100644 Binary files a/test/jpegoptim_test2.jpg and b/test/jpegoptim_test2.jpg differ diff --git a/test/test.py b/test/test.py index cf002bc..d8ce86f 100755 --- a/test/test.py +++ b/test/test.py @@ -31,6 +31,10 @@ class JpegoptimTests(unittest.TestCase): program = '../jpegoptim' debug = False + def setUp(self): + if "JPEGOPTIM" in os.environ: + self.program = os.environ["JPEGOPTIM"] + def run_test(self, args, check=True, directory=None): """execute jpegoptim for a test""" command = [self.program] + args