Skip to content

Commit

Permalink
Add unlink_files method to TestCmd, replace file deletion loops with …
Browse files Browse the repository at this point in the history
…method calls in msvs executable test scripts, re-order CHANGES.txt.
  • Loading branch information
jcbrill committed Dec 28, 2023
1 parent f9b68fe commit 6827a03
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 69 deletions.
11 changes: 7 additions & 4 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer suppo

RELEASE VERSION/DATE TO BE FILLED IN LATER

From Ataf Fazledin Ahamed:
- Use of NotImplemented instead of NotImplementedError for special methods
of _ListVariable class

From Joseph Brill:
- Fix issue #2755: the msvs tool no longer writes the OS environment SCONS_HOME
value into the SCons environment when the SCONS_HOME variable already exists
Expand All @@ -32,6 +36,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
build. The tests were modified to delete the test executable, object file,
and sconsign file prior to the command-line invocation of the VS development
binary.
- A method, unlink_files, was added to the TestCmd class that unlinks a list of
files from a specified directory. An attempt to unlink a file is made only when
the file exists, otherwise, the file is ignored.

From Michał Górny:
- Remove unecessary dependencies on pypi packages from setup.cfg
Expand All @@ -40,10 +47,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Fix of the --debug=sconscript option to return exist statements when using return
statement with stop flag enabled

From Ataf Fazledin Ahamed:
- Use of NotImplemented instead of NotImplementedError for special methods
of _ListVariable class

RELEASE 4.6.0 - Sun, 19 Nov 2023 17:22:20 -0700

From Max Bachmann:
Expand Down
5 changes: 4 additions & 1 deletion RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ Here is a summary of the changes since 4.6.0:
NEW FUNCTIONALITY
-----------------

- List new features (presumably why a checkpoint is being released)
- A method, unlink_files, was added to the TestCmd class that unlinks a list of
files from a specified directory. An attempt to unlink a file is made only when
the file exists, otherwise, the file is ignored.


DEPRECATED FUNCTIONALITY
------------------------
Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-10.0-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-10.0Exp-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-11.0-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-11.0Exp-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-14.0-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-14.0Exp-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-14.1-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-14.2-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-14.3-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-6.0-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.run(chdir='sub dir',
program=[test.get_msvs_executable(msvs_version)],
Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-7.0-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-7.1-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-8.0-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-8.0Exp-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-9.0-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))

Expand Down
5 changes: 1 addition & 4 deletions test/MSVS/vs-9.0Exp-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@

test.run(chdir='sub dir', arguments='.')

for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
filepath = test.workpath('sub dir', filename)
if os.path.exists(filepath):
test.unlink(filepath)
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))

Expand Down
25 changes: 25 additions & 0 deletions testing/framework/TestCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,31 @@ def unlink(self, file) -> None:
file = self.canonicalize(file)
os.unlink(file)

def unlink_files(self, dirpath, files):
"""Unlinks a list of file names from the specified directory.
The directory path may be a list, in which case the elements are
concatenated with the os.path.join() method.
A file name may be a list, in which case the elements are
concatenated with the os.path.join() method.
The directory path and file name are concatenated with the
os.path.join() method. The resulting file path is assumed to be
under the temporary working directory unless it is an absolute path
name. An attempt to unlink the resulting file is made only when the
file exists otherwise the file path is ignored.
"""
if is_List(dirpath):
dirpath = os.path.join(*dirpath)
for file in files:
if is_List(file):
file = os.path.join(*file)
filepath = os.path.join(dirpath, file)
filepath = self.canonicalize(filepath)
if os.path.exists(filepath):
self.unlink(filepath)

def verbose_set(self, verbose) -> None:
"""Sets the verbose level."""
self.verbose = verbose
Expand Down

0 comments on commit 6827a03

Please sign in to comment.