From 0ee16e8d85e1aa6c7c99a77ca56dc803220a0a4a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 4 Jan 2019 02:41:19 +0100 Subject: [PATCH 1/2] Reordered tests --- src/cis/{30.cis.bats => 20.cis.bats} | 0 src/cisd/{40.cisd.bats => 30.cisd.bats} | 0 src/hartree_fock/{20.hf.bats => 10.hf.bats} | 0 src/kohn_sham_rs/{21.rsks.bats => 61.rsks.bats} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/cis/{30.cis.bats => 20.cis.bats} (100%) rename src/cisd/{40.cisd.bats => 30.cisd.bats} (100%) rename src/hartree_fock/{20.hf.bats => 10.hf.bats} (100%) rename src/kohn_sham_rs/{21.rsks.bats => 61.rsks.bats} (100%) diff --git a/src/cis/30.cis.bats b/src/cis/20.cis.bats similarity index 100% rename from src/cis/30.cis.bats rename to src/cis/20.cis.bats diff --git a/src/cisd/40.cisd.bats b/src/cisd/30.cisd.bats similarity index 100% rename from src/cisd/40.cisd.bats rename to src/cisd/30.cisd.bats diff --git a/src/hartree_fock/20.hf.bats b/src/hartree_fock/10.hf.bats similarity index 100% rename from src/hartree_fock/20.hf.bats rename to src/hartree_fock/10.hf.bats diff --git a/src/kohn_sham_rs/21.rsks.bats b/src/kohn_sham_rs/61.rsks.bats similarity index 100% rename from src/kohn_sham_rs/21.rsks.bats rename to src/kohn_sham_rs/61.rsks.bats From c297dbef83fb10c92ec048d3f0ecd9f6a93624c8 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 4 Jan 2019 03:19:20 +0100 Subject: [PATCH 2/2] qp_test can run only one test --- docs/Makefile | 7 +++++-- docs/source/users_guide/qp_test.rst | 7 +++++-- scripts/qp_test | 11 +++++++---- src/cisd/30.cisd.bats | 4 ++-- tests/bats/common.bats.sh | 11 +++++++++++ tests/bats_to_sh.py | 2 +- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index 49962dac..7cb79bf2 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -11,10 +11,13 @@ BUILDDIR = build help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile +.PHONY: help Makefile auto + +auto: + cd source ; python2 auto_generate.py # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - cd source ; python2 auto_generate.py @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + diff --git a/docs/source/users_guide/qp_test.rst b/docs/source/users_guide/qp_test.rst index 0fb7ed86..2714f9c5 100644 --- a/docs/source/users_guide/qp_test.rst +++ b/docs/source/users_guide/qp_test.rst @@ -4,14 +4,17 @@ qp_test ======= -This command runs the consistency test of |qp|. The tests are run with the |Bats| shell testing environment. +This command runs the consistency test of |qp|. +The tests are run with the |Bats| shell testing environment. +If the name of a test of its number is specified on the command line, only this +test will be run. Usage ----- .. code:: bash - qp_test [FLAGS] + qp_test [FLAGS] [TEST] Flags : [-a] Run all the tests [-v] Verbose mode: shows the output of the runs diff --git a/scripts/qp_test b/scripts/qp_test index 9ed90424..182ec876 100755 --- a/scripts/qp_test +++ b/scripts/qp_test @@ -5,7 +5,7 @@ Runs all the possible tests using bats. Usage: - qp_test [-av] + qp_test [-av] [TEST] Options: -v verbose output @@ -34,6 +34,9 @@ def main(arguments): number, _ = f.split('.',1) l_bats.append( (int(number), os.path.join(dirname,f)) ) + if arguments["TEST"]: + os.environ["TEST"] = arguments["TEST"] + if arguments["-a"]: for (dirname, _, filenames) in os.walk(QP_SRC, followlinks=False) : if "IRPF90_temp" not in dirname: @@ -55,12 +58,12 @@ def main(arguments): print "" if arguments["-v"]: p1 = subprocess.Popen(["python2", "bats_to_sh.py", bats_file], \ - stdout=subprocess.PIPE) - p2 = subprocess.Popen(["bash"], stdin=p1.stdout) + stdout=subprocess.PIPE, env=os.environ) + p2 = subprocess.Popen(["bash"], stdin=p1.stdout, env=os.environ) _, _ = os.waitpid(p2.pid,0) _, _ = os.waitpid(p1.pid,0) else: - subprocess.check_call(["bats", bats_file]) + subprocess.check_call(["bats", bats_file], env=os.environ) diff --git a/src/cisd/30.cisd.bats b/src/cisd/30.cisd.bats index 0d4e57d4..f7d8bdb7 100644 --- a/src/cisd/30.cisd.bats +++ b/src/cisd/30.cisd.bats @@ -29,7 +29,7 @@ function run() { @test "[Cu(NH3)4]2+" { qp_set_mo_class cu_nh3_4_2plus.ezfio -core "[1-24]" -act "[25-45]" -del "[46-87]" - run cu_nh3_4_2plus.ezfio -1862.98687225779 -1862.68821075043 + run cu_nh3_4_2plus.ezfio -1862.98685486633 -1862.68819645070 } @test "C2H2" { @@ -70,7 +70,7 @@ function run() { @test "CH4" { qp_set_mo_class ch4.ezfio -core "[1]" -act "[2-30]" -del "[31-59]" - run ch4.ezfio -40.2403957502264 -39.8433160343413 + run ch4.ezfio -40.2403916878857 -39.8433229646061 } @test "CO2" { diff --git a/tests/bats/common.bats.sh b/tests/bats/common.bats.sh index 1e6dfb67..f2f35357 100644 --- a/tests/bats/common.bats.sh +++ b/tests/bats/common.bats.sh @@ -44,3 +44,14 @@ function test_exe() { fi } +run_only_test() { + if [[ "$BATS_TEST_DESCRIPTION" != "$1" ]] && [[ "$BATS_TEST_NUMBER" -ne "$1" ]]; then + skip + fi +} + +setup() { + if [[ -n $TEST ]] ; then + run_only_test $TEST + fi +} diff --git a/tests/bats_to_sh.py b/tests/bats_to_sh.py index 37e5fadb..30a21114 100755 --- a/tests/bats_to_sh.py +++ b/tests/bats_to_sh.py @@ -13,7 +13,7 @@ for i in raw_data: if i == "@": inside = True elif i == "{" and inside and level == 0: - new_i = "" + new_i = "\nsetup\n" elif i == "}" and inside and level == 1: inside = False new_i = ""