def test_xpidl_generation(self): """Ensure xpidl files and directories are written out.""" env = self._consume('xpidl', RecursiveMakeBackend) # Purge manifests should contain entries. purge_dir = os.path.join(env.topobjdir, '_build_manifests', 'purge') install_dir = os.path.join(env.topobjdir, '_build_manifests', 'install') self.assertTrue(os.path.isfile(os.path.join(purge_dir, 'xpidl'))) self.assertTrue(os.path.isfile(os.path.join(install_dir, 'dist_idl'))) m = PurgeManifest(path=os.path.join(purge_dir, 'xpidl')) self.assertIn('.deps/my_module.pp', m.entries) self.assertIn('xpt/my_module.xpt', m.entries) m = InstallManifest(path=os.path.join(install_dir, 'dist_idl')) self.assertEqual(len(m), 2) self.assertIn('bar.idl', m) self.assertIn('foo.idl', m) m = PurgeManifest(path=os.path.join(purge_dir, 'dist_include')) self.assertIn('foo.h', m.entries) p = os.path.join(env.topobjdir, 'config/makefiles/xpidl') self.assertTrue(os.path.isdir(p)) self.assertTrue(os.path.isfile(os.path.join(p, 'Makefile')))
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_old_purge_manifest_deleted(self): # Simulate a purge manifest from a previous backend version. Ensure it # is deleted. env = self._get_environment('stub0') purge_dir = os.path.join(env.topobjdir, '_build_manifests', 'purge') manifest_path = os.path.join(purge_dir, 'old_manifest') os.makedirs(purge_dir) m = PurgeManifest() m.write(path=manifest_path) self.assertTrue(os.path.exists(manifest_path)) self._consume('stub0', RecursiveMakeBackend, env) self.assertFalse(os.path.exists(manifest_path))
def test_serialization(self): m = PurgeManifest(relpath="rel") m.add("foo") m.add("bar") p = self.tmppath("m") m.write(path=p) self.assertTrue(os.path.exists(p)) m2 = PurgeManifest(path=p) self.assertEqual(m.relpath, m2.relpath) self.assertEqual(m.entries, m2.entries) self.assertEqual(m, m2)
def test_serialization(self): m = PurgeManifest(relpath='rel') m.add('foo') m.add('bar') p = self.tmppath('m') m.write(path=p) self.assertTrue(os.path.exists(p)) m2 = PurgeManifest(path=p) self.assertEqual(m.relpath, m2.relpath) self.assertEqual(m.entries, m2.entries) self.assertEqual(m, m2)
def process_manifest(topdir, manifest_path): manifest = PurgeManifest(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_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(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 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 _init(self): CommonBackend._init(self) self._backend_files = {} self._ipdl_sources = set() def detailed(summary): return '{:d} total backend files. {:d} created; {:d} updated; {:d} unchanged'.format( summary.managed_count, summary.created_count, summary.updated_count, summary.unchanged_count) # This is a little kludgy and could be improved with a better API. self.summary.backend_detailed_summary = types.MethodType( detailed, self.summary) self.xpcshell_manifests = [] self.backend_input_files.add( os.path.join(self.environment.topobjdir, 'config', 'autoconf.mk')) self._install_manifests = dict() self._purge_manifests = dict( dist_bin=PurgeManifest(relpath='dist/bin'), dist_include=PurgeManifest(relpath='dist/include'), dist_private=PurgeManifest(relpath='dist/private'), dist_public=PurgeManifest(relpath='dist/public'), dist_sdk=PurgeManifest(relpath='dist/sdk'), tests=PurgeManifest(relpath='_tests'), xpidl=PurgeManifest(relpath='config/makefiles/xpidl'), ) self._install_manifests = dict(dist_idl=InstallManifest(), )
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(path=p)
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_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(path=os.path.join(purge_dir, 'dist_bin')) self.assertEqual(m.relpath, 'dist/bin')
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')
def test_construct(self): m = PurgeManifest() self.assertEqual(m.relpath, '') self.assertEqual(len(m.entries), 0)