From 6cde83c2b3fe94eb7c719abb4426a10592ef48d9 Mon Sep 17 00:00:00 2001 From: Mathew Robinson Date: Fri, 24 Jan 2020 16:28:41 -0500 Subject: Clear dangling links before building targets Closes #3516 --- src/CHANGES.txt | 1 + src/engine/SCons/Node/FS.py | 26 ++++++++++++++++++++++++-- src/engine/SCons/Node/__init__.py | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 36537cf..f7a17a3 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -35,6 +35,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER unnecessary calls to eval when a token is surrounded in braces but is not a function call. - Improve performance of subst by removing unnecessary recursion. + - Cleanup dangling symlinks before running builders From Mats Wichmann: - Remove deprecated SourceCode diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 6f16256..25541e5 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -711,6 +711,20 @@ class Base(SCons.Node.Node): self._memo['stat'] = result return result + @SCons.Memoize.CountMethodCall + def lstat(self): + try: + return self._memo['lstat'] + except KeyError: + pass + try: + result = self.fs.lstat(self.get_abspath()) + except os.error: + result = None + + self._memo['lstat'] = result + return result + def exists(self): return SCons.Node._exists_map[self._func_exists](self) @@ -718,14 +732,22 @@ class Base(SCons.Node.Node): return SCons.Node._rexists_map[self._func_rexists](self) def getmtime(self): - st = self.stat() + if self.islink(): + st = self.lstat() + else: + st = self.stat() + if st: return st[stat.ST_MTIME] else: return None def getsize(self): - st = self.stat() + if self.islink(): + st = self.lstat() + else: + st = self.stat() + if st: return st[stat.ST_SIZE] else: diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 0b58282..589347c 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -137,6 +137,8 @@ def exists_always(node): return 1 def exists_base(node): + if node.islink(): + return node.lstat() is not None return node.stat() is not None def exists_entry(node): -- cgit v0.12 From 4223a2b28c279fdffe1793478897fe8cb57ef058 Mon Sep 17 00:00:00 2001 From: Mathew Robinson Date: Fri, 24 Jan 2020 17:57:56 -0500 Subject: Write test for clearing symlinks as part of FS.File.prepare --- src/engine/SCons/Node/FSTests.py | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index bbfdd1b..9a9980c 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -3559,6 +3559,56 @@ class prepareTestCase(unittest.TestCase): dir.prepare() +if sys.platform != 'win32' and hasattr(os, 'symlink'): + class CleanSymlinksTestCase(_tempdirTestCase): + + def test_cleans_symlinks(self): + """Test the prepare() method will cleanup symlinks.""" + with open("foo", "w") as foo: + foo.write("baz") + + symlink = os.symlink("foo", "bar") + bar = self.fs.File("bar") + bar.side_effect = True + bar.set_state(0) + assert bar.exists() + + bar.prepare() + try: + os.lstat("bar") + assert False, "bar should not exist" + except FileNotFoundError: + pass + + os.stat("foo") + + + def test_cleans_dangling_symlinks(self): + """Test the prepare() method will cleanup dangling symlinks.""" + with open("foo", "w") as foo: + foo.write("baz") + + symlink = os.symlink("foo", "bar") + os.remove("foo") + try: + os.stat("foo") + assert False, "foo should not exist" + except FileNotFoundError: + pass + + bar = self.fs.File("bar") + bar.side_effect = True + bar.set_state(0) + assert bar.exists() + + bar.prepare() + try: + os.lstat("bar") + assert False, "bar should not exist" + except FileNotFoundError: + pass + + class SConstruct_dirTestCase(unittest.TestCase): def runTest(self): """Test setting the SConstruct directory""" -- cgit v0.12 From 9119a54c29b317133dcbf093ba2da963cf02f09f Mon Sep 17 00:00:00 2001 From: Mathew Robinson Date: Sun, 26 Jan 2020 23:47:12 -0500 Subject: Fix dangling-include and dangling-source tests SCons.Node.FS.File.exists now properly reports False if the symlink is there but dangling. This does mean that SCons.Node.FS.File.prepare must check if File is a link when exists is False because if it is a dangling link we should still clear it. --- src/engine/SCons/Node/FS.py | 5 ++++- src/engine/SCons/Node/FSTests.py | 4 +++- src/engine/SCons/Node/__init__.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 25541e5..9f02cbb 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -3138,7 +3138,10 @@ class File(Base): SCons.Node.Node.prepare(self) if self.get_state() != SCons.Node.up_to_date: - if self.exists(): + # Exists will report False for dangling symlinks so if it + # exists or is a link (which would mean it's a dangling + # link) then we should remove it as appropriate. + if self.exists() or self.islink(): if self.is_derived() and not self.precious: self._rmv_existing() else: diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 9a9980c..ce6951d 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -3599,7 +3599,9 @@ if sys.platform != 'win32' and hasattr(os, 'symlink'): bar = self.fs.File("bar") bar.side_effect = True bar.set_state(0) - assert bar.exists() + + # Dangling links should report not exists + assert not bar.exists() bar.prepare() try: diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 589347c..96ee558 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -138,7 +138,7 @@ def exists_always(node): def exists_base(node): if node.islink(): - return node.lstat() is not None + return node.lstat() is not None and node.stat() is not None return node.stat() is not None def exists_entry(node): -- cgit v0.12 From 1b0a6037e51941e028c6c01e418d8f077d50abd2 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sat, 2 May 2020 00:22:25 -0400 Subject: revert exist_base since its not necessary --- src/engine/SCons/Node/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index dba7d8c..c3565bf 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -135,8 +135,6 @@ def exists_always(node): return 1 def exists_base(node): - if node.islink(): - return node.lstat() is not None and node.stat() is not None return node.stat() is not None def exists_entry(node): -- cgit v0.12 From 8978dc746c718d57624391f5ea15653325f3f864 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sat, 2 May 2020 00:26:24 -0400 Subject: fix sider issues --- src/engine/SCons/Node/FSTests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index ea967bb..8271c0f 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -3550,7 +3550,7 @@ if sys.platform != 'win32' and hasattr(os, 'symlink'): with open("foo", "w") as foo: foo.write("baz") - symlink = os.symlink("foo", "bar") + os.symlink("foo", "bar") bar = self.fs.File("bar") bar.side_effect = True bar.set_state(0) @@ -3571,7 +3571,7 @@ if sys.platform != 'win32' and hasattr(os, 'symlink'): with open("foo", "w") as foo: foo.write("baz") - symlink = os.symlink("foo", "bar") + os.symlink("foo", "bar") os.remove("foo") try: os.stat("foo") -- cgit v0.12 From 9e9423e1b89d9479d5bff80ad0b02dc2740bf772 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sat, 2 May 2020 15:38:05 -0400 Subject: add issue number to changes.txt --- src/CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index f3bdd07..0832c47 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -99,7 +99,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER unnecessary calls to eval when a token is surrounded in braces but is not a function call. - Improve performance of subst by removing unnecessary recursion. - - Cleanup dangling symlinks before running builders + - Cleanup dangling symlinks before running builders (Issue #3516) From Mats Wichmann: - Remove deprecated SourceCode -- cgit v0.12 From 7c4bc9a79c20f2ac1e8c5f25957fbcad87e7ff56 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 6 May 2020 20:03:49 -0700 Subject: [ci skip] Fixed to use new SCons dir location --- scripts/scons-configure-cache.py | 2 +- scripts/scons.py | 2 +- scripts/sconsign.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/scons-configure-cache.py b/scripts/scons-configure-cache.py index 62cab56..da0e848 100644 --- a/scripts/scons-configure-cache.py +++ b/scripts/scons-configure-cache.py @@ -67,7 +67,7 @@ if "SCONS_LIB_DIR" in os.environ: libs.append(os.environ["SCONS_LIB_DIR"]) # running from source takes 2nd priority (since 2.3.2), following SCONS_LIB_DIR -source_path = os.path.join(script_path, os.pardir, 'src', 'engine') +source_path = os.path.join(script_path, os.pardir) if os.path.isdir(source_path): libs.append(source_path) diff --git a/scripts/scons.py b/scripts/scons.py index 1dc6c78..9af9897 100755 --- a/scripts/scons.py +++ b/scripts/scons.py @@ -61,7 +61,7 @@ if "SCONS_LIB_DIR" in os.environ: libs.append(os.environ["SCONS_LIB_DIR"]) # running from source takes 2nd priority (since 2.3.2), following SCONS_LIB_DIR -source_path = os.path.join(script_path, os.pardir, 'src', 'engine') +source_path = os.path.join(script_path, os.pardir) if os.path.isdir(source_path): libs.append(source_path) diff --git a/scripts/sconsign.py b/scripts/sconsign.py index 493bd40..0edd05c 100644 --- a/scripts/sconsign.py +++ b/scripts/sconsign.py @@ -59,7 +59,7 @@ if "SCONS_LIB_DIR" in os.environ: libs.append(os.environ["SCONS_LIB_DIR"]) # running from source takes 2nd priority (since 2.3.2), following SCONS_LIB_DIR -source_path = os.path.join(script_path, os.pardir, 'src', 'engine') +source_path = os.path.join(script_path, os.pardir) if os.path.isdir(source_path): libs.append(source_path) -- cgit v0.12 From 463ec8562a726d502c9e6fb5ad44368140bf2a09 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 9 May 2020 10:05:49 -0600 Subject: python tool not default + minor wording tweaks Do not add the python tool (which adds Python suffices to SourceFileScanner) in the list of default tools. At the moment, it causes problems for SCons' own documentation build. Minor wording fix in python tool doc. Signed-off-by: Mats Wichmann --- SCons/Tool/__init__.py | 14 +++++++++----- SCons/Tool/python.xml | 7 ++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/SCons/Tool/__init__.py b/SCons/Tool/__init__.py index 4cb77c0..7aab554 100644 --- a/SCons/Tool/__init__.py +++ b/SCons/Tool/__init__.py @@ -1275,13 +1275,17 @@ def tool_list(platform, env): 'tar', 'zip', # File builders (text) 'textfile', - # Python scanner tool - 'python', ], env) - tools = ([linker, c_compiler, cxx_compiler, - fortran_compiler, assembler, ar, d_compiler] - + other_tools) + tools = [ + linker, + c_compiler, + cxx_compiler, + fortran_compiler, + assembler, + ar, + d_compiler, + ] + other_tools return [x for x in tools if x] diff --git a/SCons/Tool/python.xml b/SCons/Tool/python.xml index e3f7da3..17cb564 100644 --- a/SCons/Tool/python.xml +++ b/SCons/Tool/python.xml @@ -26,9 +26,10 @@ See its __doc__ string for a discussion of the format. -Loads the Python scanner scanner into the invoking environment. When loaded, the scanner will -attempt to find implicit dependencies for any Python source files in the list of sources -provided to an actual that uses this environment. +Loads the Python source scanner into the invoking environment. +When loaded, the scanner will attempt to find implicit +dependencies for any Python source files in the list of sources +provided to an Action that uses this environment. -- cgit v0.12 From 9cc2cdda99866ef7f9241bb762ab1d03989be124 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 9 May 2020 12:39:06 -0600 Subject: Add version note for Python tool [ci skip] Signed-off-by: Mats Wichmann --- SCons/Tool/python.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/SCons/Tool/python.xml b/SCons/Tool/python.xml index 17cb564..0e9fbbc 100644 --- a/SCons/Tool/python.xml +++ b/SCons/Tool/python.xml @@ -31,6 +31,7 @@ When loaded, the scanner will attempt to find implicit dependencies for any Python source files in the list of sources provided to an Action that uses this environment. +Available since &scons; 4.0.. -- cgit v0.12 From 13add860052487b3e068b216640de1e2bc309d88 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 9 May 2020 20:21:25 -0700 Subject: Address a few remaining issues with tests for issue #3516 --- SCons/Node/FSTests.py | 89 +++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/SCons/Node/FSTests.py b/SCons/Node/FSTests.py index 8271c0f..71798a9 100644 --- a/SCons/Node/FSTests.py +++ b/SCons/Node/FSTests.py @@ -32,7 +32,7 @@ import unittest import shutil import stat -from TestCmd import TestCmd +from TestCmd import TestCmd, IS_WINDOWS import TestUnit import SCons.Errors @@ -3541,57 +3541,64 @@ class prepareTestCase(unittest.TestCase): dir = fs.Dir("dir") dir.prepare() +# @unittest.skipIf(IS_WINDOWS, "No symlinks on windows") +# @unittest.skipUnless(hasattr(os, 'symlink'), "Platform doesn't support symlink") +class CleanSymlinksTestCase(_tempdirTestCase): -if sys.platform != 'win32' and hasattr(os, 'symlink'): - class CleanSymlinksTestCase(_tempdirTestCase): + def test_cleans_symlinks(self): + """Test the prepare() method will cleanup symlinks.""" - def test_cleans_symlinks(self): - """Test the prepare() method will cleanup symlinks.""" - with open("foo", "w") as foo: - foo.write("baz") + test = self.test - os.symlink("foo", "bar") - bar = self.fs.File("bar") - bar.side_effect = True - bar.set_state(0) - assert bar.exists() + with open(test.workpath("foo"), "w") as foo: + foo.write("baz") - bar.prepare() - try: - os.lstat("bar") - assert False, "bar should not exist" - except FileNotFoundError: - pass + os.symlink(test.workpath("foo"), test.workpath("bar")) + bar = self.fs.File(test.workpath("bar")) + bar.side_effect = True + bar.set_state(0) + assert bar.exists(), "Symlink %s should not exist after prepare"%str(bar) - os.stat("foo") + bar.prepare() + try: + os.lstat(test.workpath("bar")) + assert False, "bar should not exist" + except FileNotFoundError: + pass + try: + os.stat(test.workpath("foo")) + except FileNotFoundError: + test.fail('Real file %s should not be removed'%test.workpath('foo')) - def test_cleans_dangling_symlinks(self): - """Test the prepare() method will cleanup dangling symlinks.""" - with open("foo", "w") as foo: - foo.write("baz") + def test_cleans_dangling_symlinks(self): + """Test the prepare() method will cleanup dangling symlinks.""" + test = self.test - os.symlink("foo", "bar") - os.remove("foo") - try: - os.stat("foo") - assert False, "foo should not exist" - except FileNotFoundError: - pass + with open(test.workpath("foo"), "w") as foo: + foo.write("baz") - bar = self.fs.File("bar") - bar.side_effect = True - bar.set_state(0) + os.symlink(test.workpath("foo"), test.workpath("bar")) + os.remove(test.workpath("foo")) + try: + os.stat(test.workpath("foo")) + assert False, "foo should not exist" + except FileNotFoundError: + pass - # Dangling links should report not exists - assert not bar.exists() + bar = self.fs.File(test.workpath("bar")) + bar.side_effect = True + bar.set_state(0) - bar.prepare() - try: - os.lstat("bar") - assert False, "bar should not exist" - except FileNotFoundError: - pass + # Dangling links should report not exists + assert not bar.exists() + + bar.prepare() + try: + os.lstat(test.workpath("bar")) + assert False, "bar [%s] should not exist"%test.workpath("bar") + except FileNotFoundError: + pass class SConstruct_dirTestCase(unittest.TestCase): -- cgit v0.12 From 8825ac1211edb0ebdf3a098a0b962ee7ca5a4438 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 9 May 2020 20:22:59 -0700 Subject: [ci skip] Add bullet in RELEASE.txt --- RELEASE.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE.txt b/RELEASE.txt index 13548aa..843894b 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -47,6 +47,7 @@ FIXES + - Cleanup dangling symlinks before running builders (Issue #3516) - Fixed usage of abspath and path for RootDir objects on Windows. Previously env.fs.Dir("T:").abspath would return "T:\T:" and now it correctly returns "T:". - Fix Issue #3469 - Fixed improper reuse of temporary and compiled files by Configure when changing -- cgit v0.12 From 189b6de6190f6eef7914a170c70ba9db82285cdd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 10 May 2020 13:29:03 -0700 Subject: Restore commented out unittest test skipping logic --- SCons/Node/FSTests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SCons/Node/FSTests.py b/SCons/Node/FSTests.py index 71798a9..29e9d81 100644 --- a/SCons/Node/FSTests.py +++ b/SCons/Node/FSTests.py @@ -3541,8 +3541,8 @@ class prepareTestCase(unittest.TestCase): dir = fs.Dir("dir") dir.prepare() -# @unittest.skipIf(IS_WINDOWS, "No symlinks on windows") -# @unittest.skipUnless(hasattr(os, 'symlink'), "Platform doesn't support symlink") +@unittest.skipIf(IS_WINDOWS, "No symlinks on windows") +@unittest.skipUnless(hasattr(os, 'symlink'), "Platform doesn't support symlink") class CleanSymlinksTestCase(_tempdirTestCase): def test_cleans_symlinks(self): -- cgit v0.12 From 2b4bb2fcb569116a9c9ec91686994eb258d5b680 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 10 May 2020 15:55:21 -0700 Subject: Fix runtest.py to check SCons dir instead of src dir. Missed this change during repro directory refactor. --- runtest.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtest.py b/runtest.py index 893797c..a36ba85 100755 --- a/runtest.py +++ b/runtest.py @@ -10,7 +10,7 @@ # - end-to-end tests - these are *.py files in test/ directory that # require custom SCons framework from testing/ # -# This script adds src/ and testing/ directories to PYTHONPATH, +# This script adds SCons/ and testing/ directories to PYTHONPATH, # performs test discovery and processes them according to options. # # With -p (--package) option, script tests specified package from @@ -603,18 +603,18 @@ else: testpaths = [] # Each test path specifies a test file, or a directory to search for - # SCons tests. SCons code layout assumes that any file under the 'src' + # SCons tests. SCons code layout assumes that any file under the 'SCons' # subdirectory that ends with 'Tests.py' is a unit test, and any Python # script (*.py) under the 'test' subdirectory an end-to-end test. # We need to track these because they are invoked differently. # - # Note that there are some tests under 'src' that *begin* with + # Note that there are some tests under 'SCons' that *begin* with # 'test_', but they're packaging and installation tests, not # functional tests, so we don't execute them by default. (They can # still be executed by hand, though). if options.all: - testpaths = ['src', 'test'] + testpaths = ['SCons', 'test'] elif args: testpaths = args @@ -629,7 +629,7 @@ else: # sys.stderr.write("to:%s\n"%tp) for path in glob.glob(tp): if os.path.isdir(path): - if path.startswith('src') or path.startswith('testing'): + if path.startswith('SCons') or path.startswith('testing'): for p in find_unit_tests(path): unittests.append(p) elif path.startswith('test'): -- cgit v0.12 From 28646db896c6275bb031c1a711d0dfb6c878d904 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 10 May 2020 16:38:54 -0700 Subject: change runtest test to look for SCons and not src --- test/runtest/SCons.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/runtest/src.py | 74 --------------------------------------------------- 2 files changed, 74 insertions(+), 74 deletions(-) create mode 100644 test/runtest/SCons.py delete mode 100644 test/runtest/src.py diff --git a/test/runtest/SCons.py b/test/runtest/SCons.py new file mode 100644 index 0000000..9bc86e8 --- /dev/null +++ b/test/runtest/SCons.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# 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 we find tests under the SCons/ tree only if they end +with *Tests.py. +""" + +import os + +import TestRuntest + +test = TestRuntest.TestRuntest() + +test.subdir(['SCons'], + ['SCons', 'suite']) + +pythonstring = TestRuntest.pythonstring +pythonflags = TestRuntest.pythonflags +src_passTests_py = os.path.join('SCons', 'passTests.py') +src_suite_passTests_py = os.path.join('SCons', 'suite', 'passTests.py') + +test.write_passing_test(['SCons', 'pass.py']) + +test.write_passing_test(['SCons', 'passTests.py']) + +test.write_passing_test(['SCons', 'suite', 'pass.py']) + +test.write_passing_test(['SCons', 'suite', 'passTests.py']) + +expect_stdout = """\ +%(pythonstring)s%(pythonflags)s %(src_passTests_py)s +PASSING TEST STDOUT +%(pythonstring)s%(pythonflags)s %(src_suite_passTests_py)s +PASSING TEST STDOUT +""" % locals() + +expect_stderr = """\ +PASSING TEST STDERR +PASSING TEST STDERR +""" % locals() + +test.run(arguments='-k SCons', stdout=expect_stdout, stderr=expect_stderr) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/runtest/src.py b/test/runtest/src.py deleted file mode 100644 index cbce2bd..0000000 --- a/test/runtest/src.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# 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 we find tests under the src/ tree only if they end -with *Tests.py. -""" - -import os - -import TestRuntest - -test = TestRuntest.TestRuntest() - -test.subdir(['src'], - ['src', 'suite']) - -pythonstring = TestRuntest.pythonstring -pythonflags = TestRuntest.pythonflags -src_passTests_py = os.path.join('src', 'passTests.py') -src_suite_passTests_py = os.path.join('src', 'suite', 'passTests.py') - -test.write_passing_test(['src', 'pass.py']) - -test.write_passing_test(['src', 'passTests.py']) - -test.write_passing_test(['src', 'suite', 'pass.py']) - -test.write_passing_test(['src', 'suite', 'passTests.py']) - -expect_stdout = """\ -%(pythonstring)s%(pythonflags)s %(src_passTests_py)s -PASSING TEST STDOUT -%(pythonstring)s%(pythonflags)s %(src_suite_passTests_py)s -PASSING TEST STDOUT -""" % locals() - -expect_stderr = """\ -PASSING TEST STDERR -PASSING TEST STDERR -""" % locals() - -test.run(arguments='-k src', stdout=expect_stdout, stderr=expect_stderr) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From ea400bc3739b21bc2179b0bc762c531b9c6bb69b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 10 May 2020 16:39:15 -0700 Subject: Fix travis .coversagerc to look for sources under SCons and not src --- .travis/.coveragerc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis/.coveragerc b/.travis/.coveragerc index d94c366..3aaf35b 100644 --- a/.travis/.coveragerc +++ b/.travis/.coveragerc @@ -1,8 +1,8 @@ echo "[run]" >> .coveragerc -echo "source = $PWD/src" >> .coveragerc +echo "source = $PWD/SCons" >> .coveragerc echo "parallel = True" >> .coveragerc -printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> .coveragerc +printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsetup.py\n\n" >> .coveragerc echo "[path]" >> .coveragerc echo "source = $PWD" >> .coveragerc echo "[report]" >> .coveragerc -printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> .coveragerc +printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsetup.py\n\n" >> .coveragerc -- cgit v0.12 From cb6ea00154931812011f056e5d088d41564baa13 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 10 May 2020 18:33:51 -0700 Subject: Fix coverage source dir for appveyor builds --- .appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index a5d7dbe..40f13de 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -159,11 +159,11 @@ build_script: $usercustomizeText = "import os`r`nos.environ['COVERAGE_PROCESS_START'] = '$($env:COVERAGE_PROCESS_START)'`r`nimport coverage`r`ncoverage.process_startup()"; $usercustomizeText|Set-Content "$($env:PYSITEDIR)/usercustomize.py"; if ($isWindows) { - $coveragercFile = "[run]`r`nsource = $($env:APPVEYOR_BUILD_FOLDER)/src`r`nparallel = True`r`ndisable_warnings = trace-changed`r`nomit =`r`n`t*Tests.py`r`n`tsrc\test_*`r`n`tsrc\setup.py`r`n`r`n[path]`r`nsource = $($env:APPVEYOR_BUILD_FOLDER)`r`n[report]`r`nomit =`r`n`t*Tests.py`r`n`tsrc\test_*`r`n`tsrc\setup.py`r`n`r`n" + $coveragercFile = "[run]`r`nsource = $($env:APPVEYOR_BUILD_FOLDER)/SCons`r`nparallel = True`r`ndisable_warnings = trace-changed`r`nomit =`r`n`t*Tests.py`r`n`tsrc\test_*`r`n`tsrc\setup.py`r`n`r`n[path]`r`nsource = $($env:APPVEYOR_BUILD_FOLDER)`r`n[report]`r`nomit =`r`n`t*Tests.py`r`n`tsrc\test_*`r`n`tsrc\setup.py`r`n`r`n" } else { - $coveragercFile = "[run]`nsource = $($env:APPVEYOR_BUILD_FOLDER)/src`nparallel = True`ndisable_warnings = trace-changed`nomit =`n`t*Tests.py`n`tsrc/test_*`n`tsrc/setup.py`n`n[path]`nsource = $($env:APPVEYOR_BUILD_FOLDER)`n[report]`nomit =`n`t*Tests.py`n`tsrc/test_*`n`tsrc/setup.py`n`n" + $coveragercFile = "[run]`nsource = $($env:APPVEYOR_BUILD_FOLDER)/SCons`nparallel = True`ndisable_warnings = trace-changed`nomit =`n`t*Tests.py`n`tsrc/test_*`n`tsrc/setup.py`n`n[path]`nsource = $($env:APPVEYOR_BUILD_FOLDER)`n[report]`nomit =`n`t*Tests.py`n`tsrc/test_*`n`tsrc/setup.py`n`n" } $coveragercFile|Set-Content "$($env:COVERAGE_PROCESS_START)"; } -- cgit v0.12