summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2021-03-26 00:27:54 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2021-03-26 00:27:54 (GMT)
commit39eed7be98e5516429d4dfb740090ba8c5619b76 (patch)
tree034e9f0fabb210a9fb6bc54712460f7bf668fab5
parent1563927ff28b93715e5279eb842483341b8fd6c7 (diff)
downloadSCons-39eed7be98e5516429d4dfb740090ba8c5619b76.zip
SCons-39eed7be98e5516429d4dfb740090ba8c5619b76.tar.gz
SCons-39eed7be98e5516429d4dfb740090ba8c5619b76.tar.bz2
Simplify test and fix to work on all platforms
-rw-r--r--test/File/File-relpath.py38
-rw-r--r--test/File/fixture/relpath/base/SConstruct27
2 files changed, 43 insertions, 22 deletions
diff --git a/test/File/File-relpath.py b/test/File/File-relpath.py
index 48c862b..5914631 100644
--- a/test/File/File-relpath.py
+++ b/test/File/File-relpath.py
@@ -31,18 +31,32 @@ Specifically ${TARGET.relpath}, ${SOURCE.relpath} match expected path
import os
import TestSCons
+from TestCmd import IS_WINDOWS
test = TestSCons.TestSCons()
-test.subdir('src', ['src', 'dir'])
-
-test.dir_fixture('fixture/relpath')
-test.run('-Q', chdir='base', status=0, stdout="""\
-../foo/dir build/file1
-%s %s
-src/file
-%s
-src/file
-%s
-""" % (os.path.abspath('base/../foo/dir'), os.path.abspath('base/build/file1'), os.path.abspath('base/src/file'),
- os.path.abspath('base/src/file')))
+test.subdir("src", ["src", "dir"])
+
+test.dir_fixture("fixture/relpath")
+
+expected = [
+ # expanding variable, expected string
+ ("${TARGETS.relpath}", "../foo/dir build/file1"),
+ (
+ "${TARGETS.abspath}",
+ "%s %s"
+ % (os.path.abspath("base/../foo/dir"), os.path.abspath("base/build/file1")),
+ ),
+ ("${SOURCES.relpath}", "src/file"),
+ ("${SOURCES.abspath}", os.path.abspath("base/src/file")),
+ ("${SOURCE.relpath}", "src/file"),
+ ("${SOURCE.abspath}", os.path.abspath("base/src/file")),
+]
+
+expected_stdout="\n".join(["%s=%s"%(s,o) for s,o in expected])
+expected_stdout+="\nscons: `.' is up to date."
+
+if IS_WINDOWS:
+ expected_stdout = expected_stdout.replace('/', os.sep)
+
+test.run('-Q', chdir='base', status=0, stdout=expected_stdout+"\n")
diff --git a/test/File/fixture/relpath/base/SConstruct b/test/File/fixture/relpath/base/SConstruct
index af2459e..4bb5078 100644
--- a/test/File/fixture/relpath/base/SConstruct
+++ b/test/File/fixture/relpath/base/SConstruct
@@ -2,14 +2,21 @@
# This is the SConstruct for test/File/File-relpath.py
#
DefaultEnvironment(tools=[])
-Echo = Builder(action=['@echo ${TARGETS.relpath}',
- '@echo ${TARGETS.abspath}',
- '@echo ${SOURCES.relpath}',
- '@echo ${SOURCES.abspath}',
- '@echo ${SOURCE.relpath}',
- '@echo ${SOURCE.abspath}'
- ],
- )
+env = Environment(tools=[])
-env = Environment(tools=[], BUILDERS={'Echo': Echo})
-env.Echo(['../foo/dir', 'build/file1'], ['src/file'])
+input_list = [
+ "${TARGETS.relpath}",
+ "${TARGETS.abspath}",
+ "${SOURCES.relpath}",
+ "${SOURCES.abspath}",
+ "${SOURCE.relpath}",
+ "${SOURCE.abspath}",
+ ]
+outputs = env.subst(
+ input_list,
+ target=[File("../foo/dir"), File("build/file1")],
+ source=[File("src/file")],
+)
+
+for i,s in zip(input_list,outputs):
+ print("%s=%s"%(i,s))