]> git.parisson.com Git - mezzo.git/commitdiff
runtests more user-friendly
authorAntoine Lebrun <antoinelebrun@touriste-147-113.ircam.fr>
Mon, 14 May 2018 10:35:02 +0000 (12:35 +0200)
committerAntoine Lebrun <antoinelebrun@touriste-147-113.ircam.fr>
Mon, 14 May 2018 10:35:02 +0000 (12:35 +0200)
app/runtests.py [new file with mode: 0644]

diff --git a/app/runtests.py b/app/runtests.py
new file mode 100644 (file)
index 0000000..2f9c2ae
--- /dev/null
@@ -0,0 +1,58 @@
+from subprocess import call
+import sys
+tests_to_run = []
+params = []
+def choose_arguments():
+    print("\nToo few arguments. You can use : \n\n -all : to run all mezzo tests\n -mezzanine : to run only mezzanine tests")
+    print(" -agenda : to run mezzanine-agenda tests \n -organization : to run mezzanine-organization tests\n -cartridge : to run cartridge tests ")
+    print(" --front : to run only front tests \n --back : to run only back tests\n\n You can also use all manage.py options ( as --failfast)")
+    return input("\n'yes' to run all tests, 'no' to cancel : ")
+
+def execute():
+    for test in tests_to_run:
+        print("\n\n****" + test + "****")
+        call(["python", "manage.py","test" , test , "--keepdb"] + params)
+
+def add_all_tests():
+    tests_to_run.append("/srv/lib/mezzanine-agenda")
+    tests_to_run.append("/srv/lib/mezzanine")
+    tests_to_run.append("/srv/lib/mezzanine-organization")
+    tests_to_run.append("/srv/lib/cartridge")
+
+def bad_arguments():
+    if choose_arguments()=='yes':
+        add_all_tests()
+    else:
+        sys.exit()    
+
+if len(sys.argv)==1:
+    bad_arguments()
+else:
+    for arg in sys.argv:
+        if "--front" in arg:
+            params.append("--pattern=*front.py")
+        elif "--back" in arg:
+            params.append("--pattern=*back.py")
+        elif arg == "-all":
+            add_all_tests()
+        elif arg == "-agenda":
+            tests_to_run.append("/srv/lib/mezzanine-agenda")
+        elif arg == "-mezzanine":
+            tests_to_run.append("/srv/lib/mezzanine")
+        elif arg == "-organization":
+            tests_to_run.append("/srv/lib/mezzanine-organization")
+        elif arg == "-cartridge":
+            tests_to_run.append("/srv/lib/cartridge")
+        elif arg!= "runtests.py":
+            params.append(arg)
+execute()
+    
+
+
+# All : python manage.py test /srv/lib/cartridge /srv/lib/mezzanine /srv/lib/mezzanine-agenda /srv/lib/mezzanine-organization --keepdb
+# example above does not work for a strange reason  
+
+# Cartridge : python manage.py test /srv/lib/cartridge --keepdb
+# Mezzanine : python managy.py test /srv/lib/mezzanine --keepdb
+# Mezzanine-agenda : python manage.py test /srv/lib/mezzanine-agenda --keepdb
+# Mezzanine-organization : python manage.py test /srv/lib/mezzanine-organization --keepdb
\ No newline at end of file