summaryrefslogtreecommitdiff
path: root/test/Copy-Symlinks.py
diff options
context:
space:
mode:
authorWilliam Blevins <wblevins@gmail.com>2015-03-23 22:21:33 -0400
committerWilliam Blevins <wblevins@gmail.com>2015-03-23 22:21:33 -0400
commit3018e45e7e04f1a3fa6586b9a2437c885f4bb48b (patch)
tree2ff2ba871de46d88672cbcf93d13c47da5776c3e /test/Copy-Symlinks.py
parentb9e222b9d0ba04bdb65b1a221893998872547b28 (diff)
downloadscons-3018e45e7e04f1a3fa6586b9a2437c885f4bb48b.tar.gz
Issue 2395: Symlink support hotfix.
Symlink contents now copied correctly with relative path when ( cwd != symlink directory ).
Diffstat (limited to 'test/Copy-Symlinks.py')
-rw-r--r--test/Copy-Symlinks.py51
1 files changed, 45 insertions, 6 deletions
diff --git a/test/Copy-Symlinks.py b/test/Copy-Symlinks.py
index 640e76c1..2b8b8247 100644
--- a/test/Copy-Symlinks.py
+++ b/test/Copy-Symlinks.py
@@ -50,18 +50,24 @@ treeToLink = 'tree'
treelinkToCopy = 'treelinkToCopy'
badToLink = 'None' # do not write this item
badlinkToCopy = 'badlinkToCopy'
+relToLink = os.path.join( treeToLink, fileToLink )
+rellinkToCopy = 'relLinkToCopy'
test.symlink( fileToLink, filelinkToCopy )
test.symlink( dirToLink, dirlinkToCopy )
test.symlink( treeToLink, treelinkToCopy )
test.symlink( badToLink, badlinkToCopy )
+test.symlink( relToLink, rellinkToCopy )
test.write( fileToLink, fileContents )
test.subdir( dirToLink )
test.subdir( treeToLink )
-test.write( os.path.join( treeToLink, fileToLink ), fileContents )
+test.write( relToLink, fileContents )
-test.write('SConstruct',
+sconstructPath = 'SConstruct'
+sconscriptPath = os.path.join( treeToLink, 'SConscript' )
+
+test.write( sconstructPath,
"""\
import SCons.Defaults
SCons.Defaults.DefaultEnvironment( tools = [] )
@@ -81,17 +87,32 @@ Execute( Copy( 'L6', '%(treelinkToCopy)s', True ) )
Execute( Copy( 'Fails', '%(badlinkToCopy)s', False ) )
Execute( Copy( 'L7', '%(badlinkToCopy)s' ) )
Execute( Copy( 'L8', '%(badlinkToCopy)s', True ) )
+
+SConscript( '%(sconscriptPath)s' )
+"""
+% locals()
+)
+
+relLinkCopyPath = os.path.join( '..', rellinkToCopy )
+
+test.write( sconscriptPath,
+"""\
+Execute( Copy( 'F2', '%(relLinkCopyPath)s', False ) )
+Execute( Copy( 'L9', '%(relLinkCopyPath)s' ) )
+Execute( Copy( 'L10', '%(relLinkCopyPath)s', True ) )
"""
% locals()
)
-test.must_exist( 'SConstruct' )
+test.must_exist( sconstructPath )
+test.must_exist( sconscriptPath )
test.must_exist( fileToLink )
test.must_exist( filelinkToCopy )
test.must_exist( dirlinkToCopy )
test.must_exist( treelinkToCopy )
test.must_not_exist( badToLink )
test.must_exist( badlinkToCopy )
+test.must_exist( rellinkToCopy )
expectStdout = test.wrap_stdout(
read_str =
@@ -105,9 +126,12 @@ Copy("L4", "%(dirlinkToCopy)s")
Copy("T1", "%(treelinkToCopy)s")
Copy("L5", "%(treelinkToCopy)s")
Copy("L6", "%(treelinkToCopy)s")
-Copy("Fails", "badlinkToCopy")
+Copy("Fails", "%(badlinkToCopy)s")
Copy("L7", "%(badlinkToCopy)s")
Copy("L8", "%(badlinkToCopy)s")
+Copy("F2", "%(relLinkCopyPath)s")
+Copy("L9", "%(relLinkCopyPath)s")
+Copy("L10", "%(relLinkCopyPath)s")
''' % locals(),
build_str =
'''\
@@ -117,13 +141,18 @@ scons: `.' is up to date.
expectStderr = \
'''\
-scons: *** None: No such file or directory
-'''
+scons: *** %s: No such file or directory
+''' % os.path.join( os.getcwd(), badToLink )
test.run( stdout = expectStdout, stderr = expectStderr, status = None )
+F2 = os.path.join( treeToLink, 'F2' )
+L9 = os.path.join( treeToLink, 'L9' )
+L10 = os.path.join( treeToLink, 'L10' )
+
test.must_exist('D1')
test.must_exist('F1')
+test.must_exist( F2 )
test.must_exist('L2')
test.must_exist('L3')
test.must_exist('L4')
@@ -131,17 +160,21 @@ test.must_exist('L5')
test.must_exist('L6')
test.must_exist('L7')
test.must_exist('L8')
+test.must_exist( L9 )
+test.must_exist( L10 )
test.must_exist('T1')
test.must_not_exist( 'Fails' )
test.must_match( fileToLink, fileContents )
test.must_match( 'F1', fileContents )
+test.must_match( F2 , fileContents )
test.must_match( 'L1', fileContents )
test.must_match( 'L2', fileContents )
test.must_match( os.path.join( treeToLink, fileToLink ), fileContents )
test.fail_test( condition=os.path.islink('D1') )
test.fail_test( condition=os.path.islink('F1') )
+test.fail_test( condition=os.path.islink( F2 ) )
test.fail_test( condition=os.path.islink('T1') )
test.fail_test( condition=(not os.path.isdir('D1')) )
test.fail_test( condition=(not os.path.isfile('F1')) )
@@ -154,8 +187,12 @@ test.fail_test( condition=(not os.path.islink('L5')) )
test.fail_test( condition=(not os.path.islink('L6')) )
test.fail_test( condition=(not os.path.islink('L7')) )
test.fail_test( condition=(not os.path.islink('L8')) )
+test.fail_test( condition=(not os.path.islink( L9 )) )
+test.fail_test( condition=(not os.path.islink( L10 )) )
test.fail_test( condition=(os.path.exists('L7')) )
test.fail_test( condition=(os.path.exists('L8')) )
+test.fail_test( condition=(os.path.exists( L9 )) )
+test.fail_test( condition=(os.path.exists( L10 )) )
test.fail_test( condition=(os.readlink(filelinkToCopy) != os.readlink('L1')) )
test.fail_test( condition=(os.readlink(filelinkToCopy) != os.readlink('L2')) )
test.fail_test( condition=(os.readlink(dirlinkToCopy) != os.readlink('L3')) )
@@ -164,6 +201,8 @@ test.fail_test( condition=(os.readlink(treelinkToCopy) != os.readlink('L5')) )
test.fail_test( condition=(os.readlink(treelinkToCopy) != os.readlink('L6')) )
test.fail_test( condition=(os.readlink(badlinkToCopy) != os.readlink('L7')) )
test.fail_test( condition=(os.readlink(badlinkToCopy) != os.readlink('L8')) )
+test.fail_test( condition=(os.readlink(rellinkToCopy) != os.readlink( L9 )) )
+test.fail_test( condition=(os.readlink(rellinkToCopy) != os.readlink( L10 )) )
test.pass_test()