Ejemplo n.º 1
0
    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')
        kwargs = {
            'sourcedirs': [self.srcdir],
            'topsourcedir': self.srcdir,
            'jardir': os.path.join(self.builddir, 'chrome'),
        }
        jm.makeJars((os.path.join(self.srcdir,'jar.mn'),), tuple(), **kwargs)
        # 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))
Ejemplo n.º 2
0
    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')
        kwargs = {
            'sourcedirs': [self.srcdir],
            'topsourcedir': self.srcdir,
            'jardir': os.path.join(self.builddir, 'chrome'),
        }
        jm.makeJars((os.path.join(self.srcdir, 'jar.mn'), ), tuple(), **kwargs)
        # 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))
Ejemplo n.º 3
0
 def _jar_and_compare(self, *args, **kwargs):
     jm = JarMaker(outputFormat='jar')
     kwargs['jardir'] = os.path.join(self.builddir, 'chrome')
     if 'topsourcedir' not in kwargs:
         kwargs['topsourcedir'] = self.srcdir
     jm.makeJars(*args, **kwargs)
     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)
Ejemplo n.º 4
0
 def _jar_and_compare(self, *args, **kwargs):
     jm = JarMaker(outputFormat='jar')
     kwargs['jardir'] = os.path.join(self.builddir, 'chrome')
     if 'topsourcedir' not in kwargs:
         kwargs['topsourcedir'] = self.srcdir
     jm.makeJars(*args, **kwargs)
     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)