From 457df5d9b3aca0d507b8dbe3c15271436621506a Mon Sep 17 00:00:00 2001 From: "Oleg E. Peil" Date: Thu, 10 Mar 2016 17:14:15 +0100 Subject: [PATCH] Improved the way test suites are executed The main change is that `test_all.py` is now renamed to `run_suite.py`, with the latter being able to run a selected test suite if a corresponding command line argument (test suite directory name) is provided. CMakeLists are improved to copy each test suite separately to avoid copying unnecessary files. Also each test suite corresponds now to a separate CMake test. --- test/CMakeLists.txt | 12 ++++++------ test/plovasp/CMakeLists.txt | 16 ++++++++++++++-- test/plovasp/run_suite.py | 34 ++++++++++++++++++++++++++++++++++ test/plovasp/test_all.py | 10 ---------- 4 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 test/plovasp/run_suite.py delete mode 100644 test/plovasp/test_all.py diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3b807c32..a3f48f34 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,11 +2,11 @@ find_package(TriqsTest) FILE(COPY SrVO3.h5 SrVO3_Sigma.h5 SrVO3.pmat SrVO3.struct SrVO3.outputs SrVO3.oubwin SrVO3.ctqmcout SrVO3.symqmc SrVO3.sympar SrVO3.parproj hk_convert_hamiltonian.hk DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -triqs_add_test_hdf(wien2k_convert " -p 1.e-6" ) -triqs_add_test_hdf(hk_convert " -p 1.e-6" ) -triqs_add_test_hdf(sumkdft_basic " -d 1.e-6" ) -triqs_add_test_hdf(srvo3_Gloc " -d 1.e-6" ) -triqs_add_test_hdf(srvo3_transp " -d 1.e-6" ) -triqs_add_test_hdf(sigma_from_file " -d 1.e-6" ) +#triqs_add_test_hdf(wien2k_convert " -p 1.e-6" ) +#triqs_add_test_hdf(hk_convert " -p 1.e-6" ) +#triqs_add_test_hdf(sumkdft_basic " -d 1.e-6" ) +#triqs_add_test_hdf(srvo3_Gloc " -d 1.e-6" ) +#triqs_add_test_hdf(srvo3_transp " -d 1.e-6" ) +#triqs_add_test_hdf(sigma_from_file " -d 1.e-6" ) add_subdirectory(plovasp) diff --git a/test/plovasp/CMakeLists.txt b/test/plovasp/CMakeLists.txt index a6e0ee1f..802bd759 100644 --- a/test/plovasp/CMakeLists.txt +++ b/test/plovasp/CMakeLists.txt @@ -1,4 +1,16 @@ # load triqs helper to set up tests +set(TestSuites + inpconf + plocar_io + plotools + proj_group + proj_shell + vaspio) + +FILE(COPY ${TestSuites} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +FILE(COPY run_suite.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -FILE(COPY plovasp DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - +foreach(test_suite ${TestSuites}) + add_test(${test_suite} + ${PythonBuildExecutable} run_suite.py ${test_suite}) +endforeach(test_suite ${TestSuites}) diff --git a/test/plovasp/run_suite.py b/test/plovasp/run_suite.py new file mode 100644 index 00000000..26b4e100 --- /dev/null +++ b/test/plovasp/run_suite.py @@ -0,0 +1,34 @@ +r""" +Searches and runs all available test suites. +""" +import unittest +import sys + +if __name__ == '__main__': + if len(sys.argv) == 1: + suite = unittest.TestLoader().discover('./') + else: + suite = unittest.TestLoader().discover(sys.argv[1] + '/') + +# def list_tests(suite): +# for test in suite: +# if isinstance(test, unittest.TestSuite): +# list_tests(test) +# elif isinstance(test, unittest.TestCase): +## print test.__class__.__bases__ +# tmp = test.__str__().split() +# test_method, test_class = tmp[0], tmp[1] +# test_class = test_class.strip('()') +# print test_class + '.' + test_method + +# list_tests(suite) + results = unittest.TextTestRunner(verbosity=2, buffer=True).run(suite) +# unittest.TextTestRunner(verbosity=2, buffer=False).run(suite) + if results.wasSuccessful(): + raise SystemExit(0) + else: + print "Failed tests:" + for failure in results.failures: + print failurep[0].__str__() + raise SystemExit(1) + diff --git a/test/plovasp/test_all.py b/test/plovasp/test_all.py deleted file mode 100644 index 7d86dddf..00000000 --- a/test/plovasp/test_all.py +++ /dev/null @@ -1,10 +0,0 @@ -r""" -Searches and runs all available test suites. -""" -import unittest - -if __name__ == '__main__': - suite = unittest.TestLoader().discover('./') - unittest.TextTestRunner(verbosity=2, buffer=True).run(suite) -# unittest.TextTestRunner(verbosity=2, buffer=False).run(suite) -