diff options
author | Adam Gross <grossag@vmware.com> | 2020-04-02 13:58:16 (GMT) |
---|---|---|
committer | Adam Gross <grossag@vmware.com> | 2020-04-02 13:58:16 (GMT) |
commit | 7a06a452f268c81fd3f509ad46025214ad586d29 (patch) | |
tree | a26ca346a01e45ebfb7f3e4f36f45a7f1bf15eef /test/Dir | |
parent | 8686ba9c3b577f14b8d072ebf0d2f22b53ce9fbb (diff) | |
download | SCons-7a06a452f268c81fd3f509ad46025214ad586d29.zip SCons-7a06a452f268c81fd3f509ad46025214ad586d29.tar.gz SCons-7a06a452f268c81fd3f509ad46025214ad586d29.tar.bz2 |
Fix inconsistencies between RootDir attributes
The RootDir class was returning different values for path and _path as well as
different values for abspath and _abspath. This is because the underscored
versions were being set in the RootDir constructor, while the non-underscored
versions were going through the EntryProxy wrapper, which is only coded to do
a simple append of paths.
I considered trying to fix EntryProxy to detect this case but instead went with
a simpler approach where RootDir overrides the attributes that it wants to
avoid EntryProxy calls. Right now I have this as path and abspath.
Diffstat (limited to 'test/Dir')
-rw-r--r-- | test/Dir/DriveAbsPath.py | 49 | ||||
-rw-r--r-- | test/Dir/DriveAbsPath/SConstruct | 32 |
2 files changed, 81 insertions, 0 deletions
diff --git a/test/Dir/DriveAbsPath.py b/test/Dir/DriveAbsPath.py new file mode 100644 index 0000000..90cef2a --- /dev/null +++ b/test/Dir/DriveAbsPath.py @@ -0,0 +1,49 @@ +#!/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__" + +""" +Test to confirm that Dir(drive_path).abspath works on Windows. +""" + +import os +import stat + +import TestSCons +from TestCmd import IS_WINDOWS + + +if IS_WINDOWS: + test = TestSCons.TestSCons() + test.dir_fixture('DriveAbsPath') + test.run() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Dir/DriveAbsPath/SConstruct b/test/Dir/DriveAbsPath/SConstruct new file mode 100644 index 0000000..af19277 --- /dev/null +++ b/test/Dir/DriveAbsPath/SConstruct @@ -0,0 +1,32 @@ +import os +import SCons + +env = Environment() +drive = os.path.splitdrive(os.getcwd())[0] +drive_dir = env.fs.Dir(drive) + +if not isinstance(drive_dir, SCons.Node.FS.RootDir): + raise Exception('env.fs.Dir("%s") returned a %s instance of a RootDir' % + (drive, type(drive_dir))) + +drive_abspath1 = drive_dir._abspath +drive_abspath2 = drive_dir.abspath +if drive_abspath1 != drive_abspath2: + raise Exception('Calculated _abspath %s is not the same as abspath %s' % + (drive_abspath1, drive_abspath2)) +elif not os.path.exists(drive_abspath1): + raise Exception('Calculated abspath %s does not exist' % drive_abspath1) +elif drive.rstrip(os.path.sep) != drive_abspath1.rstrip(os.path.sep): + raise Exception('Real drive %s and calculated abspath %s are not the ' + 'same' % (drive, drive_abspath1)) + +drive_path1 = drive_dir._path +drive_path2 = drive_dir.path +if drive_path1 != drive_path2: + raise Exception('Calculated _path %s is not the same as path %s' % + (drive_path1, drive_path2)) +elif not os.path.exists(drive_path1): + raise Exception('Calculated path %s does not exist' % drive_path1) +elif drive.rstrip(os.path.sep) != drive_path1.rstrip(os.path.sep): + raise Exception('Real drive %s and calculated abspath %s are not the ' + 'same' % (drive, drive_abs)) |