Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions test/CacheDir/timestamp-match.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
# __COPYRIGHT__
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
Expand All @@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Verify that CAcheDir() works when using 'timestamp-match' decisions.
Expand All @@ -41,21 +40,15 @@

test.write('file.in', "file.in\n")

test.run(arguments = '--cache-show --debug=explain .')

test.run(arguments='--cache-show --debug=explain .')
test.must_match('file.out', "file.in\n")
test.up_to_date(options='--cache-show --debug=explain', arguments='.')

test.up_to_date(options = '--cache-show --debug=explain', arguments = '.')

test.sleep()

test.sleep() # delay for timestamps
test.touch('file.in')

test.not_up_to_date(options = '--cache-show --debug=explain', arguments = '.')

test.up_to_date(options = '--cache-show --debug=explain', arguments = '.')

test.up_to_date(options = '--cache-show --debug=explain', arguments = '.')
test.not_up_to_date(options='--cache-show --debug=explain', arguments='.')
test.up_to_date(options='--cache-show --debug=explain', arguments='.')
test.up_to_date(options='--cache-show --debug=explain', arguments='.')

test.pass_test()

Expand Down
24 changes: 9 additions & 15 deletions test/CacheDir/timestamp-newer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
# __COPYRIGHT__
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
Expand All @@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Verify that CAcheDir() works when using 'timestamp-newer' decisions.
Expand All @@ -41,21 +40,16 @@

test.write('file.in', "file.in\n")

test.run(arguments = '--cache-show --debug=explain .')

test.run(arguments='--cache-show --debug=explain .')
test.must_match('file.out', "file.in\n")
test.up_to_date(options='--cache-show --debug=explain', arguments='.')

test.up_to_date(options = '--cache-show --debug=explain', arguments = '.')

test.sleep()

test.sleep() # delay for timestamps
test.touch('file.in')

test.not_up_to_date(options = '--cache-show --debug=explain', arguments = '.')

test.up_to_date(options = '--cache-show --debug=explain', arguments = '.')

test.up_to_date(options = '--cache-show --debug=explain', arguments = '.')
test.not_up_to_date(options='--cache-show --debug=explain', arguments='.')
test.up_to_date(options='--cache-show --debug=explain', arguments='.')
test.up_to_date(options='--cache-show --debug=explain', arguments='.')

test.pass_test()

Expand Down
70 changes: 36 additions & 34 deletions test/Copy-Action.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
# __COPYRIGHT__
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
Expand All @@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Verify that the Copy() Action works, and preserves file modification
Expand All @@ -37,29 +36,32 @@

test = TestSCons.TestSCons()

test.write('SConstruct', """
test.write('SConstruct', """\
Execute(Copy('f1.out', 'f1.in'))
Execute(Copy(File('d2.out'), 'd2.in'))
Execute(Copy('d3.out', File('f3.in')))

def cat(env, source, target):
target = str(target[0])
with open(target, "w") as f:
for src in source:
with open(str(src), "r") as ifp:
f.write(ifp.read())

Cat = Action(cat)
env = Environment()
env.Command('bar.out', 'bar.in', [Cat,
Copy("f4.out", "f4.in"),
Copy("d5.out", "d5.in"),
Copy("d6.out", "f6.in")])
env = Environment(OUTPUT = 'f7.out', INPUT = 'f7.in')
env.Command(
'bar.out',
'bar.in',
[Cat, Copy("f4.out", "f4.in"), Copy("d5.out", "d5.in"), Copy("d6.out", "f6.in")],
)
env = Environment(OUTPUT='f7.out', INPUT='f7.in')
env.Command('f8.out', 'f8.in', [Copy('$OUTPUT', '$INPUT'), Cat])
env.Command('f9.out', 'f9.in', [Cat, Copy('${TARGET}-Copy', '$SOURCE')])

env.CopyTo( 'd4', 'f10.in' )
env.CopyAs( 'd4/f11.out', 'f11.in')
env.CopyAs( 'd4/f12.out', 'd5/f12.in')
env.CopyTo('d4', 'f10.in')
env.CopyAs('d4/f11.out', 'f11.in')
env.CopyAs('d4/f12.out', 'd5/f12.in')

env.Command('f 13.out', 'f 13.in', Copy('$TARGET', '$SOURCE'))
""")
Expand Down Expand Up @@ -87,19 +89,20 @@ def cat(env, source, target):
os.chmod('f1.in', 0o646)
os.chmod('f4.in', 0o644)

test.sleep()
test.sleep() # delay for timestamps

d4_f10_in = os.path.join('d4', 'f10.in')
d4_f11_out = os.path.join('d4', 'f11.out')
d4_f12_out = os.path.join('d4', 'f12.out')
d5_f12_in = os.path.join('d5', 'f12.in')

expect = test.wrap_stdout(read_str = """\
expect = test.wrap_stdout(
read_str="""\
Copy("f1.out", "f1.in")
Copy("d2.out", "d2.in")
Copy("d3.out", "f3.in")
""",
build_str = """\
build_str="""\
cat(["bar.out"], ["bar.in"])
Copy("f4.out", "f4.in")
Copy("d5.out", "d5.in")
Expand All @@ -112,9 +115,10 @@ def cat(env, source, target):
cat(["f8.out"], ["f8.in"])
cat(["f9.out"], ["f9.in"])
Copy("f9.out-Copy", "f9.in")
""" % locals())
""" % locals(),
)

test.run(options = '-n', arguments = '.', stdout = expect)
test.run(options='-n', arguments='.', stdout=expect)

test.must_not_exist('f1.out')
test.must_not_exist('d2.out')
Expand Down Expand Up @@ -162,23 +166,21 @@ def must_be_same(f1, f2):
for value in ['ST_MODE', 'ST_MTIME']:
v = getattr(stat, value)
if s1[v] != s2[v]:
msg = '%s[%s] %s != %s[%s] %s\n' % \
(repr(f1), value, s1[v],
repr(f2), value, s2[v],)
msg = f"{f1!r}[{value}] {s1[v]} != {f2!r}[{value}] {s2[v]}\n"
sys.stderr.write(msg)
errors = errors + 1

must_be_same('f1.out', 'f1.in')
must_be_same(['d2.out', 'file'], ['d2.in', 'file'])
must_be_same(['d3.out', 'f3.in'], 'f3.in')
must_be_same('f4.out', 'f4.in')
must_be_same(['d5.out', 'file'], ['d5.in', 'file'])
must_be_same(['d6.out', 'f6.in'], 'f6.in')
must_be_same('f7.out', 'f7.in')
must_be_same(['d4', 'f10.in'], 'f10.in')
must_be_same(['d4', 'f11.out'], 'f11.in')
must_be_same(['d4', 'f12.out'], ['d5', 'f12.in'])
must_be_same('f 13.out', 'f 13.in')
errors += 1

must_be_same('f1.out', 'f1.in')
must_be_same(['d2.out', 'file'], ['d2.in', 'file'])
must_be_same(['d3.out', 'f3.in'], 'f3.in')
must_be_same('f4.out', 'f4.in')
must_be_same(['d5.out', 'file'], ['d5.in', 'file'])
must_be_same(['d6.out', 'f6.in'], 'f6.in')
must_be_same('f7.out', 'f7.in')
must_be_same(['d4', 'f10.in'], 'f10.in')
must_be_same(['d4', 'f11.out'], 'f11.in')
must_be_same(['d4', 'f12.out'], ['d5', 'f12.in'])
must_be_same('f 13.out', 'f 13.in')

if errors:
test.fail_test()
Expand Down
20 changes: 6 additions & 14 deletions test/Decider/MD5-timestamp-Repository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
# __COPYRIGHT__
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
Expand All @@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Verify behavior of the MD5-timestamp Decider() setting when combined with Repository() usage
Expand All @@ -38,13 +37,11 @@
test.subdir('Repository', 'work')
repository = test.workpath('Repository')


test.write(['Repository','content1.in'], "content1.in 1\n")
test.write(['Repository','content2.in'], "content2.in 1\n")
test.write(['Repository','content3.in'], "content3.in 1\n")
# test.writable('Repository', 0)


test.write(['work','SConstruct'], """\
Repository(r'%s')
DefaultEnvironment(tools=[])
Expand All @@ -53,18 +50,14 @@
m.Command('content1.out', 'content1.in', Copy('$TARGET', '$SOURCE'))
m.Command('content2.out', 'content2.in', Copy('$TARGET', '$SOURCE'))
m.Command('content3.out', 'content3.in', Copy('$TARGET', '$SOURCE'))
"""%repository)
""" % repository)

test.run(chdir='work',arguments='.')

test.up_to_date(chdir='work',arguments='.')

test.sleep()

test.sleep() # delay for timestamps
test.write(['Repository','content1.in'], "content1.in 2\n")

test.touch(['Repository','content2.in'])

time_content = os.stat(os.path.join(repository,'content3.in'))[stat.ST_MTIME]
test.write(['Repository','content3.in'], "content3.in 2\n")
test.touch(['Repository','content3.in'], time_content)
Expand All @@ -76,10 +69,9 @@

expect = test.wrap_stdout("""\
Copy("content1.out", "%s")
"""%os.path.join(repository,'content1.in'))
""" % os.path.join(repository, 'content1.in'))

test.run(chdir='work', arguments='.', stdout=expect)

test.up_to_date(chdir='work', arguments='.')

test.pass_test()
Expand Down
21 changes: 6 additions & 15 deletions test/Decider/MD5-timestamp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
# __COPYRIGHT__
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
Expand All @@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Verify behavior of the MD5-timestamp Decider() setting.
Expand All @@ -49,15 +48,10 @@
test.write('content3.in', "content3.in 1\n")

test.run(arguments = '.')

test.up_to_date(arguments = '.')



test.sleep()

test.sleep() # delay for timestamps
test.write('content1.in', "content1.in 2\n")

test.touch('content2.in')

time_content = os.stat('content3.in')[stat.ST_MTIME]
Expand All @@ -73,11 +67,8 @@
Copy("content1.out", "content1.in")
""")

test.run(arguments = '.', stdout=expect)

test.up_to_date(arguments = '.')


test.run(arguments='.', stdout=expect)
test.up_to_date(arguments='.')

test.pass_test()

Expand Down
Loading