1. William Deegan
  2. SCons

Commits

William Blevins  committed f03b856

Issue 2395: Added tests from copying broken symlinks.

  • Participants
  • Parent commits 4b145ad
  • Branches default

Comments (0)

Files changed (1)

File test/Copy-Symlinks.py

View file
 dirlinkToCopy = 'dirlinkToCopy'
 treeToLink = 'tree'
 treelinkToCopy = 'treelinkToCopy'
+badToLink = 'None' # do not write this item
+badlinkToCopy = 'badlinkToCopy'
 
 try:
     test.symlink( fileToLink, filelinkToCopy )
     test.symlink( dirToLink, dirlinkToCopy )
     test.symlink( treeToLink, treelinkToCopy )
+    test.symlink( badToLink, badlinkToCopy )
 except:
     test.no_result()
 
 test.write( fileToLink, fileContents )
+test.subdir( dirToLink )
 test.subdir( treeToLink )
 test.write( os.path.join( treeToLink, fileToLink ), fileContents )
 
 Execute( Copy( 'L1', '%(filelinkToCopy)s' ) )
 Execute( Copy( 'L2', '%(filelinkToCopy)s', True ) )
 
-Execute( Mkdir( '%(dirToLink)s' ) )
 Execute( Copy( 'D1', '%(dirlinkToCopy)s', False ) )
 Execute( Copy( 'L3', '%(dirlinkToCopy)s' ) )
 Execute( Copy( 'L4', '%(dirlinkToCopy)s', True ) )
 Execute( Copy( 'T1', '%(treelinkToCopy)s', False ) )
 Execute( Copy( 'L5', '%(treelinkToCopy)s' ) )
 Execute( Copy( 'L6', '%(treelinkToCopy)s', True ) )
+
+Execute( Copy( 'Fails', '%(badlinkToCopy)s', False ) )
+Execute( Copy( 'L7', '%(badlinkToCopy)s' ) )
+Execute( Copy( 'L8', '%(badlinkToCopy)s', True ) )
 """
 % locals()
 )
 test.must_exist( filelinkToCopy )
 test.must_exist( dirlinkToCopy )
 test.must_exist( treelinkToCopy )
+test.must_not_exist( badToLink )
+test.must_exist( badlinkToCopy )
 
-expect = test.wrap_stdout(
+expectStdout = test.wrap_stdout(
 read_str =
 '''\
 Copy("F1", "%(filelinkToCopy)s")
 Copy("L1", "%(filelinkToCopy)s")
 Copy("L2", "%(filelinkToCopy)s")
-Mkdir("%(dirToLink)s")
 Copy("D1", "%(dirlinkToCopy)s")
 Copy("L3", "%(dirlinkToCopy)s")
 Copy("L4", "%(dirlinkToCopy)s")
 Copy("T1", "%(treelinkToCopy)s")
 Copy("L5", "%(treelinkToCopy)s")
 Copy("L6", "%(treelinkToCopy)s")
+Copy("Fails", "badlinkToCopy")
+Copy("L7", "%(badlinkToCopy)s")
+Copy("L8", "%(badlinkToCopy)s")
 ''' % locals(),
 build_str =
 '''\
 '''
 )
 
-test.run( stdout = expect )
+expectStderr = \
+'''\
+scons: *** None: No such file or directory
+'''
+
+test.run( stdout = expectStdout, stderr = expectStderr, status = None )
 
 test.must_exist('D1')
 test.must_exist('F1')
 test.must_exist('L4')
 test.must_exist('L5')
 test.must_exist('L6')
+test.must_exist('L7')
+test.must_exist('L8')
 test.must_exist('T1')
+test.must_not_exist( 'Fails' )
 
 test.must_match( fileToLink, fileContents )
 test.must_match( 'F1', fileContents )
 test.fail_test( condition=(not os.path.islink('L4')) )
 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=(os.path.exists('L7')) )
+test.fail_test( condition=(os.path.exists('L8')) )
 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')) )
 test.fail_test( condition=(os.readlink(dirlinkToCopy) != os.readlink('L4')) )
 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.pass_test()