From d60eb58aad993210f8333e6c61711b57fd2ab593 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Mon, 16 Sep 2013 11:33:08 +0800 Subject: [PATCH] fix cmake test --- CMakeLists.txt | 5 ++--- debian/changelog | 10 ++-------- test/test_naming.py | 25 ++++++++++++++----------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00b1d4a..a8a82fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,5 @@ install (FILES ${datafiles} DESTINATION share/pdf2htmlEX) install (FILES pdf2htmlEX.1 DESTINATION share/man/man1) enable_testing() -add_test(NAME test_naming - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND python test/test_naming.py) +add_test(test_naming + python ${CMAKE_SOURCE_DIR}/test/test_naming.py) diff --git a/debian/changelog b/debian/changelog index 308aba1..8395f4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,14 +1,8 @@ -pdf2htmlex (0.9-1~git201309161048rd4aa0-0ubuntu1) raring; urgency=low +pdf2htmlex (0.9-1~git201309161055rf3e1c-0ubuntu1) raring; urgency=low * fix cmake test for packaging - -- WANG Lu Mon, 16 Sep 2013 10:48:02 +0800 - -pdf2htmlex (0.9-1~git201309161036rd4aa0-0ubuntu1) raring; urgency=low - - * fix cmake test for packaging - - -- WANG Lu Mon, 16 Sep 2013 10:36:46 +0800 + -- WANG Lu Mon, 16 Sep 2013 10:55:04 +0800 pdf2htmlex (0.9-1~git201309161021rf2993-0ubuntu1) raring; urgency=low diff --git a/test/test_naming.py b/test/test_naming.py index c178ba2..b895695 100644 --- a/test/test_naming.py +++ b/test/test_naming.py @@ -7,14 +7,17 @@ import tempfile import shutil import subprocess -# The location where the executable is generated by the build -PDF2HTMLEX_PATH = '../pdf2htmlEX' - -# The location where the base css file, etc is stored in the build folder -DATA_DIR = '../share' - +# We assume that this file is put inside SRC_DIR/test +TEST_DIR = os.path.dirname(__file__) # The location where our test PDFs are stored -TEST_DATA_DIR = './test_data' +TEST_DATA_DIR = os.path.join(TEST_DIR, 'test_data') +# The location where the base css file, etc is stored in the build folder +DATA_DIR = os.path.join(TEST_DIR, '../share') + +# The script should be run in the directory containing the binary +# The location where the executable is generated by the build +PDF2HTMLEX_PATH = './pdf2htmlEX' + def execute_pdf2htmlex_with_args(args): """ @@ -26,9 +29,9 @@ def execute_pdf2htmlex_with_args(args): :rtype: int :return: The exit code of the command """ - executable = os.path.abspath(os.path.join(os.path.dirname(__file__), PDF2HTMLEX_PATH)) + executable = os.path.abspath(PDF2HTMLEX_PATH) - cmd = [executable, '--data-dir', os.path.abspath(os.path.join(os.path.dirname(__file__), DATA_DIR))] + cmd = [executable, '--data-dir', os.path.abspath(DATA_DIR)] for val in args: cmd.append(str(val)) @@ -74,7 +77,7 @@ def path_to_test_file(filename): :rtype: str :returns: the full path to the test file """ - return os.path.abspath(os.path.join(os.path.dirname(__file__), TEST_DATA_DIR, filename)) + return os.path.abspath(os.path.join(TEST_DATA_DIR, filename)) class OutputNamingTests(unittest.TestCase): def test_generate_single_html_default_name_single_page_pdf(self): @@ -251,7 +254,7 @@ class OutputNamingTests(unittest.TestCase): self.assertEquals(files, ['foo%%.html']) if __name__=="__main__": - executable = os.path.abspath(os.path.join(os.path.dirname(__file__), PDF2HTMLEX_PATH)) + executable = os.path.abspath(PDF2HTMLEX_PATH) if not os.path.isfile(executable) or not os.access(executable, os.X_OK): print >> sys.stderr, "Cannot locate pdf2htmlEX executable. Make sure source was built before running this test." exit(1)