summaryrefslogtreecommitdiff
path: root/tools/build/v2/test/v1_testing.py
blob: 524775fac42f95db558b0b4a5e31974d1c3672aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python

# Copyright 2002 Dave Abrahams
# Copyright 2004 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

import BoostBuild
import os
from string import strip
import re
import time

def match_re(actual,expected):
    return re.match(expected,actual,re.DOTALL) != None

t = BoostBuild.Tester(match = match_re, boost_build_path = os.path.join(os.getcwd(), ".."))
t.set_tree('v1_testing')

os.environ['TOOLS'] = 'gcc'
os.environ['NOARSCAN'] = '1'

# 1) No existing bin directories.  Both build and test ran fine. As
# expected, the residue files were a bit different: There was no
# path_test.success, and path_test.test contained the word "passed"
# instead of the path to the .cpp file.  I've haven't looked yet to
# see if the lack of the path is a problem for reporting, but
# hopefully the information is trivially available somewhere else.
t.run_build_system(arguments = 'test', status = 0)
t.expect_addition(
    ['bin/compile.test/gcc/debug/runtime-link-dynamic/compile.test'
     , 'bin/nocompile.test/gcc/debug/runtime-link-dynamic/nocompile.test'
     , 'bin/link.test/gcc/debug/runtime-link-dynamic/link.test'
     , 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test'
     , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test'])


# 2) Missing source file for the library build. path_test.test was
# deleted, so the reporting programs would know that failure
# occurred. The stdout messages also indicated what had
# happened. Excellent!
t.rename('lib.cpp', 'lib.cpp.bak')
t.run_build_system(arguments = 'test', status = 1)
t.expect_removal(
    ['bin/link.test/gcc/debug/runtime-link-dynamic/link.test'
     , 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test'
     , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test'])

# 3) Missing file restored. Worked fine; path_test.test was recreated,
# no other files were touched.
t.rename('lib.cpp.bak', 'lib.cpp')
t.run_build_system(arguments = 'test', status = 0)
t.expect_addition(
    [ 'bin/link.test/gcc/debug/runtime-link-dynamic/link.test'
     , 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test'
     , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test'])
     # I didn't add a test for 'no other files were touched', because
     # it's a little complicated. There is an expect_nothing_more()
     # function, but we actually need to spell out a lot more than
     # what we currently have to do that.

# 4) Introduced error into one of the library files, causing a library build
# compile to fail. path_test.test was deleted, so the reporting programs
# would know that failure occurred. Excellent! This is the case that has
# caused regression testing to report the wrong results in the past, so it
# was good news to see it working correctly now. We probably should figure
# out some other test cases just to be sure it is working for full coverage.
t.rename('lib.cpp', 'lib.cpp.bak')
t.rename('lib-err.cpp', 'lib.cpp')
t.touch('lib.cpp')
t.run_build_system(arguments = 'test', status=1)
t.expect_removal(
    ['bin/link.test/gcc/debug/runtime-link-dynamic/link.test'
     , 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test'
     , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test'])

# 5) Fixed the error in the library file.  The library build then worked, and
# path_test.exe was relinked, without first recompiling path_test.obj. Test was
# rerun. Exactly the right behavior!
t.rename('lib.cpp.bak', 'lib.cpp')
t.run_build_system(arguments = 'test', status = 0)
t.expect_addition(
    [ 'bin/link.test/gcc/debug/runtime-link-dynamic/link.test'
     , 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test'
     , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test'])

t.cleanup()
print 'testing complete'