def test_unknown_version(self): p = self.tmppath('bad') with open(p, 'wt') as fh: fh.write('2\n') fh.write('not relevant') with self.assertRaises(UnreadablePurgeManifest): PurgeManifest.from_path(p)
def test_exports(self): """Ensure EXPORTS is written out correctly.""" env = self._consume('exports', RecursiveMakeBackend) backend_path = os.path.join(env.topobjdir, 'backend.mk') lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]] self.assertEqual(lines, [ 'MOZBUILD_DERIVED := 1', 'NO_MAKEFILE_RULE := 1', 'NO_SUBMAKEFILES_RULE := 1', 'EXPORTS += foo.h', 'EXPORTS_NAMESPACES += mozilla', 'EXPORTS_mozilla += mozilla1.h mozilla2.h', 'EXPORTS_NAMESPACES += mozilla/dom', 'EXPORTS_mozilla/dom += dom1.h dom2.h', 'EXPORTS_NAMESPACES += mozilla/gfx', 'EXPORTS_mozilla/gfx += gfx.h', 'EXPORTS_NAMESPACES += nspr/private', 'EXPORTS_nspr/private += pprio.h', ]) # EXPORTS files should appear in the dist_include purge manifest. m = PurgeManifest.from_path(os.path.join(env.topobjdir, '_build_manifests', 'purge', 'dist_include')) self.assertIn('foo.h', m.entries) self.assertIn('mozilla/mozilla1.h', m.entries) self.assertIn('mozilla/dom/dom2.h', m.entries)
def process_manifest(topdir, manifest_path): manifest = PurgeManifest.from_path(manifest_path) purger = manifest.get_purger() full = os.path.join(topdir, manifest.relpath) state = dict(relpath=manifest.relpath, result=None) t = threading.Thread(target=do_purge, args=(purger, full, state)) state["thread"] = t t.start() return state
def test_serialization(self): m = PurgeManifest(relpath='rel') m.add('foo') m.add('bar') p = self.tmppath('m') m.write_file(p) self.assertTrue(os.path.exists(p)) m2 = PurgeManifest.from_path(p) self.assertEqual(m.relpath, m2.relpath) self.assertEqual(m.entries, m2.entries) self.assertEqual(m, m2)
def test_purge_manifests_written(self): env = self._consume('stub0', RecursiveMakeBackend) purge_dir = os.path.join(env.topobjdir, '_build_manifests', 'purge') self.assertTrue(os.path.exists(purge_dir)) expected = [ 'dist_bin', 'dist_include', 'dist_private', 'dist_public', 'dist_sdk', 'tests', ] for e in expected: full = os.path.join(purge_dir, e) self.assertTrue(os.path.exists(full)) m = PurgeManifest.from_path(os.path.join(purge_dir, 'dist_bin')) self.assertEqual(m.relpath, 'dist/bin')