3 Generates a bash script, that executes py.test or nosetest on each file
9 Generating py.test isolated testsuite...
10 Done. Run '/tmp/test_sympy.sh'.
14 $ bin/test_isolated -h
18 from os
import chmod
, getcwd
20 from optparse
import OptionParser
21 from stat
import S_IREAD
, S_IWRITE
, S_IXUSR
, S_IRGRP
, S_IROTH
, S_IXGRP
, S_IXOTH
23 filemode
= S_IREAD | S_IWRITE | S_IXUSR | S_IRGRP | S_IROTH | S_IXGRP | S_IXOTH
25 def get_paths(level
=6):
27 Generates a set of paths for testfiles searching.
31 ['sympy/test_*.py', 'sympy/*/test_*.py', 'sympy/*/*/test_*.py']
33 ['sympy/test_*.py', 'sympy/*/test_*.py', 'sympy/*/*/test_*.py',
34 'sympy/*/*/*/test_*.py', 'sympy/*/*/*/*/test_*.py',
35 'sympy/*/*/*/*/*/test_*.py', 'sympy/*/*/*/*/*/*/test_*.py']
38 for i
in range(level
):
39 wildcards
.append(wildcards
[-1]+"*/")
41 p
= [my_dir
+"/sympy"+x
+"test_*.py" for x
in wildcards
]
44 def generate_test_script1(testlib
="py.test"):
45 """Generates a bash script for doing the test.
47 "testlib" is the name of the executable, that is going to execute the test,
48 for example "py.test" or "nosetests".
51 for x
in get_paths(10):
53 f
= open("/tmp/test_sympy.sh","w")
54 f
.write("#! /bin/sh\n")
55 f
.write("# Autogenerated script for a reliable test of SymPy.\n")
56 f
.write("# Execute with 'sh test_sympy.sh' (in any directory).\n\n")
58 f
.write(testlib
+" " + x
+ "\n")
59 chmod(f
.name
, filemode
)
61 def generate_test_script2(testlib
="nosetests"):
62 """Generates a bash script for doing the test.
64 "testlib" is the name of the executable, that is going to execute the test,
65 for example "py.test" or "nosetests".
68 for x
in get_paths(10):
70 f
= open("/tmp/test_sympy.sh","w")
71 f
.write("#! /bin/sh\n")
72 f
.write("# Autogenerated script for a reliable test of SymPy.\n")
73 f
.write("# Execute with 'sh test_sympy.sh' (in any directory).\n\n")
75 f
.write(testlib
+" " + x
+ " && \\\n")
76 f
.write("echo 'all tests passed, ok to commit'")
77 chmod(f
.name
, filemode
)
80 parser
= OptionParser()
81 parser
.add_option("-p","--py.test", action
="store_false", dest
="nosetests",
82 help="Use py.test (default)")
83 parser
.add_option("-n","--nosetests", action
="store_true", dest
="nosetests",
85 parser
.add_option("-q","--quiet", action
="store_false", dest
="verbose")
86 parser
.set_defaults(nosetests
=False, verbose
=True)
88 options
, args
= parser
.parse_args()
90 parser
.error("too many arguments")
93 print "Generating nosetests isolated testsuite..."
94 generate_test_script2("nosetests")
97 print "Generating py.test isolated testsuite..."
98 generate_test_script1("py.test")
100 print "Done. Run '/tmp/test_sympy.sh'."
102 if __name__
== "__main__":