|
Boost-Commit : |
From: jurko.gospodnetic_at_[hidden]
Date: 2008-05-01 20:36:23
Author: jurko
Date: 2008-05-01 20:36:23 EDT (Thu, 01 May 2008)
New Revision: 45001
URL: http://svn.boost.org/trac/boost/changeset/45001
Log:
Added a new regression test making sure that the Boost Jam SORT builtin rule does not start getting quadratic behavior in some special cases as well as testing that the sorting algorithm works correctly. Related to the patch committed in revision 44195. Trimmed trailing spaces in tools/build/v2/test/test_all.py.
Added:
trunk/tools/build/v2/test/sort_rule.py (contents, props changed)
Text files modified:
trunk/tools/build/v2/test/test_all.py | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
Added: trunk/tools/build/v2/test/sort_rule.py
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/test/sort_rule.py 2008-05-01 20:36:23 EDT (Thu, 01 May 2008)
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+
+# Copyright (C) Jurko Gospodnetic 2008.
+# 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()
+
+ 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("-d1 -f test.jam", pass_toolset=False, use_test_config=False)
+ 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()
+
+ 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("-d1 -f test.jam", pass_toolset=False, use_test_config=False, expected_duration=1)
+ t.expect_output_line("starting up")
+ t.expect_output_line("done")
+
+ t.cleanup()
+
+
+################################################################################
+#
+# main()
+# ------
+#
+################################################################################
+
+testSORTCorrectness()
+testSORTDuration()
Modified: trunk/tools/build/v2/test/test_all.py
==============================================================================
--- trunk/tools/build/v2/test/test_all.py (original)
+++ trunk/tools/build/v2/test/test_all.py 2008-05-01 20:36:23 EDT (Thu, 01 May 2008)
@@ -16,13 +16,13 @@
'BOOST_ROOT','BOOST_BUILD_PATH','JAM_TOOLSET','BCCROOT',
'MSVCDir','MSVC','MSVCNT','MINGW','watcom'
):
-
+
try:
del os.environ[s]
except:
pass
-BoostBuild.set_defer_annotations(1)
+BoostBuild.set_defer_annotations(1)
def run_tests(critical_tests, other_tests):
"""Runs first critical tests and then other_tests.
@@ -59,7 +59,7 @@
BoostBuild.flush_annotations();
pass_count = pass_count + 1
sys.stdout.flush() # makes testing under emacs more entertaining.
-
+
# Erase the file on success
if failures_count == 0:
open('test_results.txt', 'w')
@@ -69,7 +69,7 @@
PASS: %d
FAIL: %d
""" % (pass_count, failures_count)
-
+
def last_failed_test():
"Returns the name of last failed test or None"
@@ -87,7 +87,7 @@
except ValueError:
return tests
-
+
critical_tests = ["unit_tests", "module_actions", "startup_v1", "startup_v2"]
critical_tests += ["core_d12", "core_typecheck", "core_delete_module",
@@ -167,6 +167,7 @@
"example_make",
"remove_requirement",
"free_features_request",
+ "sort_rule"
]
if os.name == 'posix':
@@ -193,7 +194,7 @@
tests.append("example_customization")
# Requires gettext tools.
tests.append("example_gettext")
-
+
else:
print 'Note: skipping extra tests'
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk