Bug 741287 - Make expandlibs_gen.py error out when given a missing file. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 06 Apr 2012 10:16:25 +0200
changeset 94465 748db85b1a01b04023ca5a7593842adbc7b28d52
parent 94464 f40757e784769060757a20580cec27972dd97f4a
child 94466 d405b4adf7f96dac993efa25ee5ec4c285ccde61
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs741287
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 741287 - Make expandlibs_gen.py error out when given a missing file. r=ted
config/expandlibs_gen.py
config/tests/unit-expandlibs.py
js/src/config/expandlibs_gen.py
--- a/config/expandlibs_gen.py
+++ b/config/expandlibs_gen.py
@@ -42,16 +42,21 @@ import sys
 import os
 import expandlibs_config as conf
 from expandlibs import LibDescriptor, isObject
 
 def generate(args):
     desc = LibDescriptor()
     for arg in args:
         if isObject(arg):
-            desc['OBJS'].append(os.path.abspath(arg))
-        elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX and \
-             (os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX)):
-            desc['LIBS'].append(os.path.abspath(arg))
+            if os.path.exists(arg):
+                desc['OBJS'].append(os.path.abspath(arg))
+            else:
+                raise Exception("File not found: %s" % arg)
+        elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX:
+            if os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
+                desc['LIBS'].append(os.path.abspath(arg))
+            else:
+                raise Exception("File not found: %s" % arg)
     return desc
 
 if __name__ == '__main__':
     print generate(sys.argv[1:])
--- a/config/tests/unit-expandlibs.py
+++ b/config/tests/unit-expandlibs.py
@@ -140,16 +140,19 @@ class TestExpandLibsGen(TestCaseWithTmpD
                  [Lib('a'), Obj('b'), Lib('c'), Obj('d'), Obj('e'), Lib('f')]]
         self.touch(files[:-1])
         self.touch([files[-1] + config.LIBS_DESC_SUFFIX])
 
         desc = generate(files)
         self.assertEqual(desc['OBJS'], [self.tmpfile(Obj(s)) for s in ['b', 'd', 'e']])
         self.assertEqual(desc['LIBS'], [self.tmpfile(Lib(s)) for s in ['a', 'c', 'f']])
 
+        self.assertRaises(Exception, generate, files + [self.tmpfile(Obj('z'))])
+        self.assertRaises(Exception, generate, files + [self.tmpfile(Lib('y'))])
+
 class TestExpandInit(TestCaseWithTmpDir):
     def init(self):
         ''' Initializes test environment for library expansion tests'''
         super(TestExpandInit, self).init()
         # Create 2 fake libraries, each containing 3 objects, and the second
         # including the first one and another library.
         os.mkdir(self.tmpfile('libx'))
         os.mkdir(self.tmpfile('liby'))
--- a/js/src/config/expandlibs_gen.py
+++ b/js/src/config/expandlibs_gen.py
@@ -42,16 +42,21 @@ import sys
 import os
 import expandlibs_config as conf
 from expandlibs import LibDescriptor, isObject
 
 def generate(args):
     desc = LibDescriptor()
     for arg in args:
         if isObject(arg):
-            desc['OBJS'].append(os.path.abspath(arg))
-        elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX and \
-             (os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX)):
-            desc['LIBS'].append(os.path.abspath(arg))
+            if os.path.exists(arg):
+                desc['OBJS'].append(os.path.abspath(arg))
+            else:
+                raise Exception("File not found: %s" % arg)
+        elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX:
+            if os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
+                desc['LIBS'].append(os.path.abspath(arg))
+            else:
+                raise Exception("File not found: %s" % arg)
     return desc
 
 if __name__ == '__main__':
     print generate(sys.argv[1:])