2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-11 11:42:14 +00:00
Files
build/test/generators_test.py
Jurko Gospodnetić 343b4d6532 Updated the internal Boost Build testing system to use the Python subprocess module (introduced in Python 2.4) for running external processes instead of popen2 (deprecated since Python 2.6). We are already using Python 2.4 features in this codebase so there is no need to support Python releases older than 2.4.
Related changes:
  * BoostBuild.Tester & TestCmd.TestCmd interfaces now accept external process parameters as a list of strings, thus avoiding problems with parsing arguments containing spaces.
  * Avoided a potential process hang in case an external process being run prints out enough output to fill up the OS's pipe buffer (OS would pause the process until someone read the data from the pipe but the testing framework would not do this until the process in question had terminated).

[SVN r79448]
2012-07-12 12:55:25 +00:00

49 lines
1.7 KiB
Python

#!/usr/bin/python
# Copyright 2003 Dave Abrahams
# Copyright 2002, 2003, 2005 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 re
def match_count_is(lines, pattern, expected):
count = 0
for x in lines:
if re.search(pattern, x):
count += 1
if count > expected:
return False
return count == expected
t = BoostBuild.Tester()
t.set_tree("generators-test")
t.run_build_system(["-d1"])
t.expect_addition("bin/$toolset/debug/" * BoostBuild.List("a.my_exe a.my_obj "
"b.my_obj c.tui_h c.cpp c.my_obj d_parser.whl d_lexer.dlp d_parser.cpp "
" d_lexer.cpp d_lexer.my_obj d_parser.lr0 d_parser.h d_parser.my_obj "
"d_parser_symbols.h x.c x.my_obj y.x1 y.x2 y.cpp y.my_obj e.marked_cpp "
"e.positions e.target_cpp e.my_obj e.my_exe f.my_exe obj_1.my_obj "
"obj_2.my_obj"))
t.expect_addition("lib/bin/$toolset/debug/" * BoostBuild.List("c.my_obj "
"auxilliary.my_lib"))
t.expect_nothing_more()
t.expect_content_line("bin/$toolset/debug/obj_1.my_obj", "Sources: 'z.cpp'")
t.expect_content_line("bin/$toolset/debug/obj_2.my_obj", "Sources: 'z.cpp'")
t.expect_content_line("bin/$toolset/debug/a.my_obj", "Sources: 'a.cpp'")
lines = t.stdout().splitlines()
source_lines = [x for x in lines if re.match("^ Sources: '", x)]
if not match_count_is(source_lines, "'z.cpp'", 2):
BoostBuild.annotation("failure", "z.cpp must be compiled exactly twice.")
t.fail_test(1)
if not match_count_is(source_lines, "'a.cpp'", 1):
BoostBuild.annotation("failure", "a.cpp must be compiled exactly once.")
t.fail_test(1)
t.cleanup()