def test_a_simple_symlink(self): '''Test a simple jar.mn with a symlink''' if not symlinks_supported(self.srcdir): return self._create_simple_setup() jm = JarMaker(outputFormat='symlink') jm.sourcedirs = [self.srcdir] jm.topsourcedir = self.srcdir jardir = os.path.join(self.builddir, 'chrome') jm.makeJar(os.path.join(self.srcdir,'jar.mn'), jardir) # All we do is check that srcdir/bar points to builddir/chrome/test/dir/foo srcbar = os.path.join(self.srcdir, 'bar') destfoo = os.path.join(self.builddir, 'chrome', 'test', 'dir', 'foo') self.assertTrue(is_symlink_to(destfoo, srcbar), "%s is not a symlink to %s" % (destfoo, srcbar))
def test_a_simple_symlink(self): '''Test a simple jar.mn with a symlink''' if not symlinks_supported(self.srcdir): return self._create_simple_setup() jm = JarMaker(outputFormat='symlink') jm.sourcedirs = [self.srcdir] jm.topsourcedir = self.srcdir jardir = os.path.join(self.builddir, 'chrome') jm.makeJar(os.path.join(self.srcdir, 'jar.mn'), jardir) # All we do is check that srcdir/bar points to builddir/chrome/test/dir/foo srcbar = os.path.join(self.srcdir, 'bar') destfoo = os.path.join(self.builddir, 'chrome', 'test', 'dir', 'foo') self.assertTrue(is_symlink_to(destfoo, srcbar), "{0} is not a symlink to {1}".format(destfoo, srcbar))
def _jar_and_compare(self, infile, **kwargs): jm = JarMaker(outputFormat='jar') jardir = os.path.join(self.builddir, 'chrome') if 'topsourcedir' not in kwargs: kwargs['topsourcedir'] = self.srcdir for attr in ('topsourcedir', 'sourcedirs'): if attr in kwargs: setattr(jm, attr, kwargs[attr]) jm.makeJar(infile, jardir) cwd = os.getcwd() os.chdir(self.builddir) try: # expand build to stage for path, dirs, files in os.walk('.'): stagedir = os.path.join(self.stagedir, path) if not os.path.isdir(stagedir): os.mkdir(stagedir) for file in files: if file.endswith('.jar'): # expand jar stagepath = os.path.join(stagedir, file) os.mkdir(stagepath) zf = ZipFile(os.path.join(path, file)) # extractall is only in 2.6, do this manually :-( for entry_name in zf.namelist(): segs = entry_name.split('/') fname = segs.pop() dname = os.path.join(stagepath, *segs) if not os.path.isdir(dname): os.makedirs(dname) if not fname: # directory, we're done continue _c = zf.read(entry_name) open(os.path.join(dname, fname), 'wb').write(_c) zf.close() else: copy2(os.path.join(path, file), stagedir) # compare both dirs os.chdir('..') td = _TreeDiff('ref', 'stage') return td.allResults('reference', 'build') finally: os.chdir(cwd)