Skip to content

Commit

Permalink
Support tests via CMake as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjko committed Oct 29, 2023
1 parent 24b32a6 commit ad44b36
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=$<TARGET_FILE:jpegoptim>")
endif()
Binary file modified test/jpegoptim_test2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ad44b36

Please sign in to comment.