2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-10 23:32:20 +00:00
Files
build/test/project_test3.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

134 lines
4.0 KiB
Python

#!/usr/bin/python
# Copyright 2002, 2003 Dave Abrahams
# Copyright 2002, 2003, 2004, 2006 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
t = BoostBuild.Tester(translate_suffixes=0)
# First check some startup.
t.set_tree("project-test3")
os.remove("jamroot.jam")
t.run_build_system(status=1, stdout="""\
error: Could not find parent for project at '.'
error: Did not find Jamfile.jam or Jamroot.jam in any parent directory.
""")
t.set_tree("project-test3")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/a.obj")
t.expect_content("bin/$toolset/debug/a.obj", """\
$toolset/debug
a.cpp
""")
t.expect_addition("bin/$toolset/debug/a.exe")
t.expect_content("bin/$toolset/debug/a.exe",
"$toolset/debug\n" +
"bin/$toolset/debug/a.obj lib/bin/$toolset/debug/b.obj " +
"lib2/bin/$toolset/debug/c.obj lib2/bin/$toolset/debug/d.obj " +
"lib2/helper/bin/$toolset/debug/e.obj " +
"lib3/bin/$toolset/debug/f.obj\n"
)
t.expect_addition("lib/bin/$toolset/debug/b.obj")
t.expect_content("lib/bin/$toolset/debug/b.obj", """\
$toolset/debug
lib/b.cpp
""")
t.expect_addition("lib/bin/$toolset/debug/m.exe")
t.expect_content("lib/bin/$toolset/debug/m.exe", """\
$toolset/debug
lib/bin/$toolset/debug/b.obj lib2/bin/$toolset/debug/c.obj
""")
t.expect_addition("lib2/bin/$toolset/debug/c.obj")
t.expect_content("lib2/bin/$toolset/debug/c.obj", """\
$toolset/debug
lib2/c.cpp
""")
t.expect_addition("lib2/bin/$toolset/debug/d.obj")
t.expect_content("lib2/bin/$toolset/debug/d.obj", """\
$toolset/debug
lib2/d.cpp
""")
t.expect_addition("lib2/bin/$toolset/debug/l.exe")
t.expect_content("lib2/bin/$toolset/debug/l.exe", """\
$toolset/debug
lib2/bin/$toolset/debug/c.obj bin/$toolset/debug/a.obj
""")
t.expect_addition("lib2/helper/bin/$toolset/debug/e.obj")
t.expect_content("lib2/helper/bin/$toolset/debug/e.obj", """\
$toolset/debug
lib2/helper/e.cpp
""")
t.expect_addition("lib3/bin/$toolset/debug/f.obj")
t.expect_content("lib3/bin/$toolset/debug/f.obj", """\
$toolset/debug
lib3/f.cpp lib2/helper/bin/$toolset/debug/e.obj
""")
t.touch("a.cpp")
t.run_build_system()
t.expect_touch(["bin/$toolset/debug/a.obj",
"bin/$toolset/debug/a.exe",
"lib2/bin/$toolset/debug/l.exe"])
t.run_build_system(["release", "optimization=off,speed"])
t.expect_addition(["bin/$toolset/release/a.exe",
"bin/$toolset/release/a.obj",
"bin/$toolset/release/optimization-off/a.exe",
"bin/$toolset/release/optimization-off/a.obj"])
t.run_build_system(["--clean-all"])
t.expect_removal(["bin/$toolset/debug/a.obj",
"bin/$toolset/debug/a.exe",
"lib/bin/$toolset/debug/b.obj",
"lib/bin/$toolset/debug/m.exe",
"lib2/bin/$toolset/debug/c.obj",
"lib2/bin/$toolset/debug/d.obj",
"lib2/bin/$toolset/debug/l.exe",
"lib3/bin/$toolset/debug/f.obj"])
# Now test target ids in command line.
t.set_tree("project-test3")
t.run_build_system(["lib//b.obj"])
t.expect_addition("lib/bin/$toolset/debug/b.obj")
t.expect_nothing_more()
t.run_build_system(["--clean", "lib//b.obj"])
t.expect_removal("lib/bin/$toolset/debug/b.obj")
t.expect_nothing_more()
t.run_build_system(["lib//b.obj"])
t.expect_addition("lib/bin/$toolset/debug/b.obj")
t.expect_nothing_more()
t.run_build_system(["release", "lib2/helper//e.obj", "/lib3//f.obj"])
t.expect_addition("lib2/helper/bin/$toolset/release/e.obj")
t.expect_addition("lib3/bin/$toolset/release/f.obj")
t.expect_nothing_more()
# Test project ids in command line work as well.
t.set_tree("project-test3")
t.run_build_system(["/lib2"])
t.expect_addition("lib2/bin/$toolset/debug/" * BoostBuild.List("c.obj d.obj l.exe"))
t.expect_addition("bin/$toolset/debug/a.obj")
t.expect_nothing_more()
t.run_build_system(["lib"])
t.expect_addition("lib/bin/$toolset/debug/" * BoostBuild.List("b.obj m.exe"))
t.expect_nothing_more()
t.cleanup()