File: timedata.py

package info (click to toggle)
boost-build 2.0-m11-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,624 kB
  • ctags: 2,387
  • sloc: ansic: 12,978; python: 5,209; xml: 4,782; cpp: 555; yacc: 456; sh: 237; makefile: 71
file content (57 lines) | stat: -rwxr-xr-x 1,213 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/python
# Copyright David Abrahams 2005. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

# This tests the build step timing facilities.

import BoostBuild

t = BoostBuild.Tester(pass_toolset=0)

t.write('file.jam', '''
rule time
{
    DEPENDS $(<) : $(>) ;
    __TIMING_RULE__ on $(>) = record_time $(<) ;
    DEPENDS all : $(<) ;
}
actions time
{
    echo $(>) user: $(__USER_TIME__) system: $(__SYSTEM_TIME__)
    echo timed from $(>) >> $(<)
}

rule record_time ( target source : user : system )
{
    ECHO record_time called: $(target) / $(source) / $(user) / $(system) ;
    __USER_TIME__ on $(target) = $(user) ;
    __SYSTEM_TIME__ on $(target) = $(system) ;
}

rule make
{
    DEPENDS $(<) : $(>) ;
}
actions make
{
    echo made from $(>) >> $(<)
}


time foo : bar ;
make bar : baz ;
''')

import re
t.write('baz', 'nothing\n')
t.run_build_system(
    '-ffile.jam',
    stdout=r'bar +user: [0-9\.]+ +system: +[0-9\.]+ *$',
    match = lambda actual,expected: re.search(expected,actual,re.DOTALL)
    )
t.expect_addition('foo')
t.expect_addition('bar')
t.expect_nothing_more()

t.cleanup()