Browse Source

Tests enhancements 3

prieto 8 years ago
parent
commit
610b4d4f55
3 changed files with 37 additions and 2 deletions
  1. 25
    1
      nocontext_tests.py
  2. 7
    0
      progs/slim/install_model/loader.py
  3. 5
    1
      runtest.sh

+ 25
- 1
nocontext_tests.py View File

@@ -1,13 +1,37 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
+##@brief Loader for tests which do not need an lodel installation
4
+#
5
+# Options
6
+################
7
+# 
8
+# @note We can pass the path to a directory to write results file, nocontext_tests.log
9
+# It has to be at first, otherwise it will not be taken 
10
+# and the default one, current directory, will be used.
11
+# The results are not displayed, only stored in nocontext_tests.log
12
+#
13
+# -f, --failfast
14
+#
15
+#    Stop the test run on the first error or failure.
16
+# -v --verbose
17
+#
18
+#   higher verbosity
19
+#
20
+#
21
+
3 22
 import sys, os, os.path
4 23
 import unittest
5 24
 import nocontext_tests
6 25
 
7 26
 loader = unittest.TestLoader()
8 27
 
28
+if ((len(sys.argv) > 1) and (sys.argv[1].startswith('-')) is False):
29
+	dpath = sys.argv[1]
30
+else:
31
+	dpath = '.'
32
+
9 33
 suite = loader.discover('tests', pattern='nc_test*.py')
10
-with open(sys.argv[1]+'/nocontext_tests.log', 'w') as logfile:
34
+with open(dpath+'/nocontext_tests.log', 'w') as logfile:
11 35
     unittest.TextTestRunner(
12 36
     	logfile,
13 37
         failfast = '-f' in sys.argv,

+ 7
- 0
progs/slim/install_model/loader.py View File

@@ -5,6 +5,9 @@
5 5
 #@note If you want to avoid settings loading you can set the environment
6 6
 #variable LODEL2_NO_SETTINGS_LOAD (see @ref install.lodel_admin.update_plugin_discover_cache()
7 7
 #
8
+# @note In tests case, you can pass the path to write results file, context_tests.log 
9
+# It has to be at first, otherwise it will not be taken 
10
+# and the default one, current directory, will be used.
8 11
 
9 12
 import sys, os, os.path
10 13
 #
@@ -64,6 +67,10 @@ if __name__ == '__main__':
64 67
         loader = unittest.TestLoader()
65 68
         test_dir = os.path.join(LODEL2_LIB_ABS_PATH, 'tests')
66 69
         suite = loader.discover(test_dir, pattern='test*.py')
70
+        if ((len(sys.argv) > 1) and (sys.argv[1].startswith('-')) is False):
71
+            dpath = sys.argv[1]
72
+        else:
73
+            dpath = '.'
67 74
         with open(sys.argv[1]+'/context_tests.log', 'w') as logfile:
68 75
             unittest.TextTestRunner(
69 76
                 logfile,

+ 5
- 1
runtest.sh View File

@@ -6,7 +6,6 @@
6 6
 # Running all discoverables tests :
7 7
 # ./runtest
8 8
 #
9
-# Options
10 9
 ################
11 10
 # -f, --failfast
12 11
 #
@@ -19,6 +18,11 @@
19 18
 # -d 1 : results are displayed when tests finish and kept in logfiles in /tmp/logXXXXXXX repository, with XXXXXXX a timestamp
20 19
 # -d 2 : results are displayed when tests finish, they are not stored
21 20
 #
21
+# Furthermore
22
+################
23
+# Most of the tests need an install of lodel for dependencies reasons
24
+# For those which not need, prefix the python file by 'nc_' (example nc_test_query.py)
25
+# they will be executed outside a lodel install
22 26
 # More details :
23 27
 ################
24 28
 #

Loading…
Cancel
Save