From 4921b4564b9a712478f3a561f4541e32f50c5d83 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (l)" Date: Mon, 26 Sep 2016 09:35:53 +0200 Subject: [PATCH] started repairing test --- CMakeLists.txt | 2 +- test/test.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fdabb0..8aa0dd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,4 +216,4 @@ install (FILES ${PDF2HTMLEX_RESOURCE} DESTINATION share/pdf2htmlEX) install (FILES pdf2htmlEX.1 DESTINATION share/man/man1) enable_testing() -add_test(test python ${CMAKE_SOURCE_DIR}/test/test.py) +add_test(test python ${CMAKE_SOURCE_DIR}/test/test.py ${CMAKE_BINARY_DIR}/bin/pdf2htmlEX) diff --git a/test/test.py b/test/test.py index 3d4ee8c..5cfaf16 100755 --- a/test/test.py +++ b/test/test.py @@ -9,6 +9,10 @@ import subprocess class Common(object): SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + print "DEBUG 1: ", __file__ + print "DEBUG 2: ", os.path.abspath(__file__) + print "DEBUG 3: ", os.path.dirname(os.path.abspath(__file__)) + print "DEBUG 4: ", SRC_DIR TEST_DIR = os.path.join(SRC_DIR, 'test') DATA_DIR = os.path.join(SRC_DIR, 'share') PDF2HTMLEX_PATH = os.path.join(SRC_DIR, 'pdf2htmlEX') @@ -17,7 +21,7 @@ class Common(object): GENERATING_MODE = bool(os.environ.get('P2H_TEST_GEN')) CANONICAL_TEMPDIR = '/tmp/pdf2htmlEX_test' - + def setUp(self): if not self.SAVE_TMP: self.cur_temp_dir = tempfile.mkdtemp(prefix='pdf2htmlEX_test') @@ -30,7 +34,7 @@ class Common(object): self.cur_output_dir = os.path.join(self.cur_temp_dir, 'out') os.mkdir(self.cur_data_dir) os.mkdir(self.cur_output_dir) - + # filter manifest with open(os.path.join(self.DATA_DIR, 'manifest')) as inf: with open(os.path.join(self.cur_data_dir, 'manifest'), 'w') as outf: @@ -59,7 +63,7 @@ class Common(object): Execute the pdf2htmlEX with the specified arguments. :type args: list of values - :param args: list of arguments to pass to executable. + :param args: list of arguments to pass to executable. :return: an object of relevant info """ @@ -75,13 +79,16 @@ class Common(object): files = os.listdir(self.cur_output_dir) - return { + return { 'return_code' : return_code, 'output_files' : files } - + if __name__ == '__main__': + if not len(sys.argv)==2: + print >> sys.stderr, "Usage: python test.py " + exit(1) if not os.path.isfile(Common.PDF2HTMLEX_PATH) or not os.access(Common.PDF2HTMLEX_PATH, os.X_OK): print >> sys.stderr, "Cannot locate pdf2htmlEX executable. Make sure source was built before running this test." exit(1) @@ -104,7 +111,7 @@ if __name__ == '__main__': if name.find('.') == -1: for m in all_classes: test_names.append(m + '.' + name) - + for module in all_modules: if len(test_names) > 0 and module.__name__ not in test_names: for n in test_names: