From af6b2afffaa25d0630807b16add9d614f6d85454 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Jul 2020 12:17:49 -0700 Subject: Add test for defaulted TEMPFILEDIR behavior as well --- test/TempFileMunge/TEMPFILEDIR.py | 43 +++++++++++++++-------- test/TempFileMunge/fixture/SConstruct.tempfiledir | 6 ++++ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/test/TempFileMunge/TEMPFILEDIR.py b/test/TempFileMunge/TEMPFILEDIR.py index c1ed6f9..ced2fe9 100644 --- a/test/TempFileMunge/TEMPFILEDIR.py +++ b/test/TempFileMunge/TEMPFILEDIR.py @@ -24,29 +24,44 @@ Verify that setting the $TEMPFILEDIR variable will cause the generated tempfile used for long command lines to be created in specified directory. And if not specified in one of TMPDIR, TEMP or TMP (based on os' normal usage of such) """ -import os.path +from re import escape +import tempfile import TestSCons test = TestSCons.TestSCons(match=TestSCons.match_re) test.file_fixture('fixture/SConstruct.tempfiledir', 'SConstruct') -test.write('foo.in', "foo.in\n") - -test.run(arguments='-n -Q .', - stdout="""\ -Using tempfile \\S+ for command line: +expected_output = r"""Using tempfile __WORKDIR__/my_temp_files/\S+ for command line: xxx.py foo.out foo.in -xxx.py \\S+ -""") +xxx.py @__WORKDIR__/my_temp_files/\S+ +Using tempfile __TEMPDIR__/\S+ for command line: +xxx.py global_foo.out foo.in +xxx.py @__TEMPDIR__/\S+ +""" -try: - tempfile = test.stdout().splitlines()[0].split()[2] -except IndexError: - test.fail_test("Unexpected output couldn't find tempfile") +wd_escaped = escape(test.workdir) +td_escaped = escape(tempfile.gettempdir()) +expected_output =expected_output.replace("__WORKDIR__", wd_escaped) +expected_output = expected_output.replace("__TEMPDIR__", td_escaped) -dirname = os.path.basename(os.path.dirname(tempfile)) -test.fail_test('my_temp_files' != dirname, message="Temp file not created in \"my_temp_files\" directory") +test.write('foo.in', "foo.in\n") + +test.run(arguments='-n -Q .', + stdout=expected_output) +# """\ +# Using tempfile \\S+ for command line: +# xxx.py foo.out foo.in +# xxx.py \\S+ +# """) +# +# try: +# tempfile = test.stdout().splitlines()[0].split()[2] +# except IndexError: +# test.fail_test("Unexpected output couldn't find tempfile") +# +# dirname = os.path.basename(os.path.dirname(tempfile)) +# test.fail_test('my_temp_files' != dirname, message="Temp file not created in \"my_temp_files\" directory") test.pass_test() # Local Variables: diff --git a/test/TempFileMunge/fixture/SConstruct.tempfiledir b/test/TempFileMunge/fixture/SConstruct.tempfiledir index 6b7300d..ea26c27 100644 --- a/test/TempFileMunge/fixture/SConstruct.tempfiledir +++ b/test/TempFileMunge/fixture/SConstruct.tempfiledir @@ -9,3 +9,9 @@ env = Environment( ) env.AppendENVPath('PATH', os.curdir) env.Command('foo.out', 'foo.in', '$BUILDCOM') + +plain_env = Environment( + BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH=16, +) +plain_env.Command('global_foo.out', 'foo.in', '$BUILDCOM') -- cgit v0.12