mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 12:22:17 +00:00
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]
97 lines
2.4 KiB
Python
Executable File
97 lines
2.4 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
# Copyright (C) 2008. Jurko Gospodnetic
|
|
# 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)
|
|
|
|
# Tests for the Boost Jam builtin SORT rule.
|
|
|
|
import BoostBuild
|
|
|
|
|
|
###############################################################################
|
|
#
|
|
# testSORTCorrectness()
|
|
# ---------------------
|
|
#
|
|
###############################################################################
|
|
|
|
def testSORTCorrectness():
|
|
"""Testing that Boost Jam's SORT builtin rule actually sorts correctly."""
|
|
t = BoostBuild.Tester(["-ftest.jam", "-d1"], pass_toolset=False,
|
|
use_test_config=False)
|
|
|
|
t.write("test.jam", """\
|
|
NOCARE all ;
|
|
source-data = 1 8 9 2 7 3 4 7 1 27 27 9 98 98 1 1 4 5 6 2 3 4 8 1 -2 -2 0 0 0 ;
|
|
target-data = -2 -2 0 0 0 1 1 1 1 1 2 2 27 27 3 3 4 4 4 5 6 7 7 8 8 9 9 98 98 ;
|
|
ECHO "starting up" ;
|
|
sorted-data = [ SORT $(source-data) ] ;
|
|
ECHO "done" ;
|
|
if $(sorted-data) != $(target-data)
|
|
{
|
|
ECHO "Source :" $(source-data) ;
|
|
ECHO "Expected :" $(target-data) ;
|
|
ECHO "SORT returned:" $(sorted-data) ;
|
|
EXIT "SORT error" : -2 ;
|
|
}
|
|
""")
|
|
|
|
t.run_build_system()
|
|
t.expect_output_line("starting up")
|
|
t.expect_output_line("done")
|
|
t.expect_output_line("SORT error", False)
|
|
|
|
t.cleanup()
|
|
|
|
|
|
###############################################################################
|
|
#
|
|
# testSORTDuration()
|
|
# ------------------
|
|
#
|
|
###############################################################################
|
|
|
|
def testSORTDuration():
|
|
"""
|
|
Regression test making sure Boost Jam's SORT builtin rule does not get
|
|
quadratic behaviour again in this use case.
|
|
|
|
"""
|
|
t = BoostBuild.Tester(["-ftest.jam", "-d1"], pass_toolset=False,
|
|
use_test_config=False)
|
|
|
|
f = open(t.workpath("test.jam"), "w")
|
|
print >> f, "data = "
|
|
for i in range(0, 20000):
|
|
if i % 2 != 0:
|
|
print >> f, '"aaa"'
|
|
else:
|
|
print >> f, '"bbb"'
|
|
print >> f, """;
|
|
|
|
ECHO "starting up" ;
|
|
sorted = [ SORT $(data) ] ;
|
|
ECHO "done" ;
|
|
NOCARE all ;
|
|
"""
|
|
f.close()
|
|
|
|
t.run_build_system(expected_duration=1)
|
|
t.expect_output_line("starting up")
|
|
t.expect_output_line("done")
|
|
|
|
t.cleanup()
|
|
|
|
|
|
###############################################################################
|
|
#
|
|
# main()
|
|
# ------
|
|
#
|
|
###############################################################################
|
|
|
|
testSORTCorrectness()
|
|
testSORTDuration()
|