def test_source_path(self): config = self.config ctxt = Context(config=config) ctxt.push_source(mozpath.join(config.topsrcdir, 'foo', 'moz.build')) path = SourcePath(ctxt, 'qux') self.assertEqual(path, 'qux') self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, 'foo', 'qux')) self.assertEqual(path.translated, mozpath.join(config.topobjdir, 'foo', 'qux')) path = SourcePath(ctxt, '../bar/qux') self.assertEqual(path, '../bar/qux') self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, 'bar', 'qux')) self.assertEqual(path.translated, mozpath.join(config.topobjdir, 'bar', 'qux')) path = SourcePath(ctxt, '/qux/qux') self.assertEqual(path, '/qux/qux') self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, 'qux', 'qux')) self.assertEqual(path.translated, mozpath.join(config.topobjdir, 'qux', 'qux')) with self.assertRaises(ValueError): SourcePath(ctxt, '!../bar/qux') with self.assertRaises(ValueError): SourcePath(ctxt, '!/qux/qux') path = SourcePath(path) self.assertIsInstance(path, SourcePath) self.assertEqual(path, '/qux/qux') self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, 'qux', 'qux')) self.assertEqual(path.translated, mozpath.join(config.topobjdir, 'qux', 'qux')) path = Path(path) self.assertIsInstance(path, SourcePath)
def test_source_path(self): config = self.config ctxt = Context(config=config) ctxt.push_source(mozpath.join(config.topsrcdir, "foo", "moz.build")) path = SourcePath(ctxt, "qux") self.assertEqual(path, "qux") self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, "foo", "qux")) self.assertEqual(path.translated, mozpath.join(config.topobjdir, "foo", "qux")) path = SourcePath(ctxt, "../bar/qux") self.assertEqual(path, "../bar/qux") self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, "bar", "qux")) self.assertEqual(path.translated, mozpath.join(config.topobjdir, "bar", "qux")) path = SourcePath(ctxt, "/qux/qux") self.assertEqual(path, "/qux/qux") self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, "qux", "qux")) self.assertEqual(path.translated, mozpath.join(config.topobjdir, "qux", "qux")) with self.assertRaises(ValueError): SourcePath(ctxt, "!../bar/qux") with self.assertRaises(ValueError): SourcePath(ctxt, "!/qux/qux") path = SourcePath(path) self.assertIsInstance(path, SourcePath) self.assertEqual(path, "/qux/qux") self.assertEqual(path.full_path, mozpath.join(config.topsrcdir, "qux", "qux")) self.assertEqual(path.translated, mozpath.join(config.topobjdir, "qux", "qux")) path = Path(path) self.assertIsInstance(path, SourcePath)
def source_path(self, path): return SourcePath(self._context, path)