2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-20 14:42:14 +00:00

Don't wait after each run of bjam. Instead, wait for time change before

making any change to filesystem by the tester classes.


[SVN r14238]
This commit is contained in:
Vladimir Prus
2002-06-25 14:55:27 +00:00
parent e4f51ea789
commit b82cff2b59
2 changed files with 34 additions and 16 deletions

View File

@@ -42,6 +42,7 @@ class Tester(TestCmd.TestCmd):
TestCmd.match_exact, boost_build_path = None):
self.original_workdir = os.getcwd()
self.last_build_time = 0
jam_build_dir = ""
if os.name == 'nt':
@@ -53,7 +54,7 @@ class Tester(TestCmd.TestCmd):
if boost_build_path is None:
boost_build_path = os.path.join(self.original_workdir, "..", "new")
TestCmd.TestCmd.__init__(
self
, program=os.path.join(
@@ -91,6 +92,7 @@ class Tester(TestCmd.TestCmd):
def write(self, file, content):
self.wait_for_time_change()
try:
os.makedirs(os.path.dirname(file))
except:
@@ -98,9 +100,11 @@ class Tester(TestCmd.TestCmd):
open(self.native_file_name(file), "wb").write(content)
def copy(self, src, dst):
self.wait_for_time_change()
self.write(dst, self.read(src))
def touch(self, names):
self.wait_for_time_change()
if not type(names) == types.ListType:
names = [names]
for name in names:
@@ -113,7 +117,7 @@ class Tester(TestCmd.TestCmd):
def run_build_system(
self, extra_args='', subdir='', stdout = None, stderr = '',
status = 0, match = None, **kw):
self.previous_tree = build_tree(self.workdir)
if match is None:
@@ -143,7 +147,7 @@ class Tester(TestCmd.TestCmd):
print "STDERR ============"
print self.stderr()
self.fail_test(1)
if not stdout is None and not match(self.stdout(), stdout):
print "Expected STDOUT =========="
print stdout
@@ -154,7 +158,7 @@ class Tester(TestCmd.TestCmd):
print "STDERR ==================="
print stderr
self.fail_test(1)
if not stderr is None and not match(self.stderr(), stderr):
print "STDOUT ==================="
print self.stdout()
@@ -167,10 +171,8 @@ class Tester(TestCmd.TestCmd):
self.tree = build_tree(self.workdir)
self.difference = trees_difference(self.previous_tree, self.tree)
self.unexpected_difference = copy.deepcopy(self.difference)
# We want to assure that modifications to the working dir will be
# detected by jam, so we wait till current time becomes more that
# the time when the last target was built.
time.sleep(1.1)
self.last_build_time = time.time
def read(self, name):
return open(self.native_file_name(name), "rb").read()
@@ -294,6 +296,13 @@ class Tester(TestCmd.TestCmd):
elements = string.split(name, "/")
return apply(os.path.join, [self.workdir]+elements)
# Wait while time is no longer equal to the time last "run_build_system"
# call finished.
def wait_for_time_change(self):
while int(time.time()) == self.last_build_time:
os.sleep(0.1)
class List:
def __init__(self, s=""):

View File

@@ -42,6 +42,7 @@ class Tester(TestCmd.TestCmd):
TestCmd.match_exact, boost_build_path = None):
self.original_workdir = os.getcwd()
self.last_build_time = 0
jam_build_dir = ""
if os.name == 'nt':
@@ -53,7 +54,7 @@ class Tester(TestCmd.TestCmd):
if boost_build_path is None:
boost_build_path = os.path.join(self.original_workdir, "..", "new")
TestCmd.TestCmd.__init__(
self
, program=os.path.join(
@@ -91,6 +92,7 @@ class Tester(TestCmd.TestCmd):
def write(self, file, content):
self.wait_for_time_change()
try:
os.makedirs(os.path.dirname(file))
except:
@@ -98,9 +100,11 @@ class Tester(TestCmd.TestCmd):
open(self.native_file_name(file), "wb").write(content)
def copy(self, src, dst):
self.wait_for_time_change()
self.write(dst, self.read(src))
def touch(self, names):
self.wait_for_time_change()
if not type(names) == types.ListType:
names = [names]
for name in names:
@@ -113,7 +117,7 @@ class Tester(TestCmd.TestCmd):
def run_build_system(
self, extra_args='', subdir='', stdout = None, stderr = '',
status = 0, match = None, **kw):
self.previous_tree = build_tree(self.workdir)
if match is None:
@@ -143,7 +147,7 @@ class Tester(TestCmd.TestCmd):
print "STDERR ============"
print self.stderr()
self.fail_test(1)
if not stdout is None and not match(self.stdout(), stdout):
print "Expected STDOUT =========="
print stdout
@@ -154,7 +158,7 @@ class Tester(TestCmd.TestCmd):
print "STDERR ==================="
print stderr
self.fail_test(1)
if not stderr is None and not match(self.stderr(), stderr):
print "STDOUT ==================="
print self.stdout()
@@ -167,10 +171,8 @@ class Tester(TestCmd.TestCmd):
self.tree = build_tree(self.workdir)
self.difference = trees_difference(self.previous_tree, self.tree)
self.unexpected_difference = copy.deepcopy(self.difference)
# We want to assure that modifications to the working dir will be
# detected by jam, so we wait till current time becomes more that
# the time when the last target was built.
time.sleep(1.1)
self.last_build_time = time.time
def read(self, name):
return open(self.native_file_name(name), "rb").read()
@@ -294,6 +296,13 @@ class Tester(TestCmd.TestCmd):
elements = string.split(name, "/")
return apply(os.path.join, [self.workdir]+elements)
# Wait while time is no longer equal to the time last "run_build_system"
# call finished.
def wait_for_time_change(self):
while int(time.time()) == self.last_build_time:
os.sleep(0.1)
class List:
def __init__(self, s=""):