~inkscape.dev/inkwaf/trunk

« back to all changes in this revision

Viewing changes to test/Test.py

  • Committer: Krzysztof Kosiński
  • Date: 2010-01-08 22:55:44 UTC
  • Revision ID: tweenk.pl@gmail.com-20100108225544-bo80t5rt8n4psxwz
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# encoding: utf-8
 
3
# Thomas Nagy, 2005 (ita)
 
4
# Yinon Ehrlich, 2008, 2009
 
5
 
 
6
"Some waf tests"
 
7
 
 
8
import os
 
9
import sys
 
10
import imp
 
11
import time
 
12
 
 
13
class DIRS:
 
14
        WAFADMIN        = "wafadmin"
 
15
        WAF                     = "waf"
 
16
        DEMOS           = "demos"
 
17
        TOOLS           = "Tools"
 
18
 
 
19
# allow importing from wafadmin dir.
 
20
wafadmin = os.path.join(os.path.abspath(os.path.pardir), DIRS.WAFADMIN)
 
21
waftools = os.path.join(wafadmin, DIRS.TOOLS)
 
22
sys.path = [wafadmin, waftools] + sys.path
 
23
 
 
24
import Options
 
25
import Utils
 
26
 
 
27
# shortcut
 
28
writelines = sys.stderr.write
 
29
 
 
30
def info(msg):
 
31
        Utils.pprint('CYAN', msg)
 
32
 
 
33
def testname(file, tests_dir='test'):
 
34
        test_file=os.path.join(tests_dir, file)
 
35
        return open(test_file, 'r')
 
36
 
 
37
def run_tests():
 
38
        if Options.options:
 
39
                verbose = Options.options.verbose
 
40
        else:
 
41
                verbose = 1
 
42
 
 
43
        tests_modules = '''configure_test build_dir cxx_test gcc_test ar_test
 
44
wscript_errors_test scripting build options task_gen'''.split()
 
45
 
 
46
        all_results = []
 
47
        not_passed = []
 
48
        total = 0
 
49
        t1 = time.time()
 
50
        
 
51
        curdir = os.path.dirname(__file__)
 
52
        sys.path.append(curdir)
 
53
 
 
54
        for test in tests_modules:
 
55
                mod = imp.load_source(test, os.path.join(curdir, test + '.py'))
 
56
                writelines("******** %s ********\n" % mod.__name__)
 
57
 
 
58
                # run_tests return a TestResult instance
 
59
                result = mod.run_tests(verbose)
 
60
                total += result.testsRun
 
61
 
 
62
                # accumulate results for future stat etc.
 
63
                if not result.wasSuccessful():
 
64
                        not_passed += (result.failures + result.errors)
 
65
 
 
66
                # TODO: all_results is not used now, may be used for further investigation...
 
67
                all_results.append(result)
 
68
 
 
69
        writelines('\n' + '='*80 + '\n')
 
70
        if not_passed:
 
71
#               for t in not_passed:
 
72
#                       writelines( "%s: %s\n" % (t[0]._testMethodName, t[1]) )
 
73
                writelines( "\n%d (out of %d) tests didn't passed !" %          (len(not_passed), total) )
 
74
        else:
 
75
                writelines( "\nall tests (%d) passed successfully !\n" % total )
 
76
        t2 = time.time()
 
77
        elapsed = t2-t1
 
78
        writelines('\nall tests took %.2f seconds.\n' % elapsed)
 
79
        writelines('='*80 + '\n')
 
80
 
 
81
 
 
82
        return len(not_passed)
 
83
 
 
84
 
 
85
if __name__ == "__main__":
 
86
        # XXX: not works !
 
87
        os.chdir(os.path.pardir)
 
88
        sys.exit(run_tests())