From 61a384e83c5211a3f5eac50489ff30bc85b553d3 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 24 Jul 2018 15:41:47 -0400 Subject: [PATCH] Bug 1476973 - part 2 - assert that XPIDL_SOURCES files all exist; r=gps We should have been checking for this from the beginning. --- python/mozbuild/mozbuild/frontend/emitter.py | 4 ++++ python/mozbuild/mozbuild/test/backend/data/xpidl/bar.idl | 0 python/mozbuild/mozbuild/test/backend/data/xpidl/foo.idl | 0 .../mozbuild/test/frontend/data/missing-xpidl/moz.build | 6 ++++++ python/mozbuild/mozbuild/test/frontend/test_emitter.py | 7 +++++++ 5 files changed, 17 insertions(+) create mode 100644 python/mozbuild/mozbuild/test/backend/data/xpidl/bar.idl create mode 100644 python/mozbuild/mozbuild/test/backend/data/xpidl/foo.idl create mode 100644 python/mozbuild/mozbuild/test/frontend/data/missing-xpidl/moz.build diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 849b2d758e3c..c09cd9cb36ba 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -1385,6 +1385,10 @@ class TreeMetadataEmitter(LoggingMixin): '{path}: DIST_INSTALL = False has no effect on XPIDL_SOURCES.') for idl in context['XPIDL_SOURCES']: + if not os.path.exists(idl.full_path): + raise SandboxValidationError('File %s from XPIDL_SOURCES ' + 'does not exist' % idl.full_path, context) + yield XPIDLFile(context, idl, xpidl_module) def _process_generated_files(self, context): diff --git a/python/mozbuild/mozbuild/test/backend/data/xpidl/bar.idl b/python/mozbuild/mozbuild/test/backend/data/xpidl/bar.idl new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/mozbuild/mozbuild/test/backend/data/xpidl/foo.idl b/python/mozbuild/mozbuild/test/backend/data/xpidl/foo.idl new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/mozbuild/mozbuild/test/frontend/data/missing-xpidl/moz.build b/python/mozbuild/mozbuild/test/frontend/data/missing-xpidl/moz.build new file mode 100644 index 000000000000..75b16dfa8fb4 --- /dev/null +++ b/python/mozbuild/mozbuild/test/frontend/data/missing-xpidl/moz.build @@ -0,0 +1,6 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +XPIDL_MODULE = 'my_module' +XPIDL_SOURCES = ['nonexistant.idl'] diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py index abab8fc6c6d9..02901f44163c 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -1127,6 +1127,13 @@ class TestEmitterBasic(unittest.TestCase): reader = self.reader('xpidl-module-no-sources') self.read_topsrcdir(reader) + def test_xpidl_module_no_sources(self): + """Missing XPIDL_SOURCES should be rejected.""" + with self.assertRaisesRegexp(SandboxValidationError, 'File .* ' + 'from XPIDL_SOURCES does not exist'): + reader = self.reader('missing-xpidl') + self.read_topsrcdir(reader) + def test_missing_local_includes(self): """LOCAL_INCLUDES containing non-existent directories should be rejected.""" with self.assertRaisesRegexp(SandboxValidationError, 'Path specified in '