зеркало из https://github.com/mozilla/pjs.git
Bug 740795 part B - make nsinstall.py accept an "-X" flag to exclude files when copying directories recursively, r=ted
--HG-- extra : rebase_source : 83107535ea0fa76cf35c4a70c9e9cefb4178274b
This commit is contained in:
Родитель
c3595709ff
Коммит
01b5bbcf14
|
@ -34,6 +34,8 @@ def nsinstall(argv):
|
|||
help="Create link (ignored)")
|
||||
p.add_option('-L', action="store", metavar="linkprefix",
|
||||
help="Link prefix (ignored)")
|
||||
p.add_option('-X', action="append", metavar="file",
|
||||
help="Ignore a file when installing a directory recursively.")
|
||||
|
||||
# The remaining arguments are not used in our tree, thus they're not
|
||||
# implented.
|
||||
|
@ -75,12 +77,18 @@ def nsinstall(argv):
|
|||
os.makedirs(args[0])
|
||||
return 0
|
||||
|
||||
if options.X:
|
||||
options.X = [os.path.abspath(p) for p in options.X]
|
||||
|
||||
# nsinstall arg1 [...] directory
|
||||
if len(args) < 2:
|
||||
p.error('not enough arguments')
|
||||
|
||||
def copy_all_entries(entries, target):
|
||||
for e in entries:
|
||||
if options.X and os.path.abspath(e) in options.X:
|
||||
continue
|
||||
|
||||
dest = os.path.join(target,
|
||||
os.path.basename(os.path.normpath(e)))
|
||||
handleTarget(e, dest)
|
||||
|
|
|
@ -47,11 +47,25 @@ class TestNsinstall(unittest.TestCase):
|
|||
"Test nsinstall <dir> <dest dir>"
|
||||
sourcedir = self.mkdirs("sourcedir")
|
||||
self.touch("testfile", sourcedir)
|
||||
Xfile = self.touch("Xfile", sourcedir)
|
||||
copieddir = self.mkdirs("sourcedir/copieddir")
|
||||
self.touch("testfile2", copieddir)
|
||||
Xdir = self.mkdirs("sourcedir/Xdir")
|
||||
self.touch("testfile3", Xdir)
|
||||
|
||||
destdir = self.mkdirs("destdir")
|
||||
self.assertEqual(nsinstall([sourcedir, destdir]), 0)
|
||||
|
||||
self.assertEqual(nsinstall([sourcedir, destdir,
|
||||
'-X', Xfile,
|
||||
'-X', Xdir]), 0)
|
||||
|
||||
testdir = os.path.join(destdir, "sourcedir")
|
||||
self.assert_(os.path.isdir(testdir))
|
||||
self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))
|
||||
self.assert_(not os.path.exists(os.path.join(testdir, "Xfile")))
|
||||
self.assert_(os.path.isdir(os.path.join(testdir, "copieddir")))
|
||||
self.assert_(os.path.isfile(os.path.join(testdir, "copieddir", "testfile2")))
|
||||
self.assert_(not os.path.exists(os.path.join(testdir, "Xdir")))
|
||||
|
||||
def test_nsinstall_multiple(self):
|
||||
"Test nsinstall <three files> <dest dir>"
|
||||
|
|
Загрузка…
Ссылка в новой задаче