Bug 1459880 - part a: Use a |with| statement to open exclusion files; r=jandem
authorMs2ger <Ms2ger@igalia.com>
Tue, 08 May 2018 16:15:31 +0200
changeset 474078 c1a42cd3277611fd9356f11d450da775a467d465
parent 474077 370b059664527629e95b3ff6e9aaabea04b846e9
child 474079 c388fb0d97f4cee3aec3d42ef3ca1e2c475be62c
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1459880
milestone62.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 1459880 - part a: Use a |with| statement to open exclusion files; r=jandem This is somewhat simpler, and yields a clearer error message if the file can't be opened. (In this case, an exception is thrown before |fp| is defined, and the |fp.close()| call then throws another exception, hiding the first one.)
js/src/tests/jstests.py
--- a/js/src/tests/jstests.py
+++ b/js/src/tests/jstests.py
@@ -220,25 +220,24 @@ def parse_args():
                 [line.strip() for line in open(test_file).readlines()])
 
     excluded_paths = set(options.excluded_paths)
 
     # If files with lists of tests to exclude were specified, add them to the
     # excluded tests set.
     if options.exclude_file:
         for filename in options.exclude_file:
-            try:
-                fp = open(filename, 'r')
+            with open(filename, 'r') as fp:
                 for line in fp:
-                    if line.startswith('#'): continue
+                    if line.startswith('#'):
+                        continue
                     line = line.strip()
-                    if not line: continue
-                    excluded_paths |= set((line,))
-            finally:
-                fp.close()
+                    if not line:
+                        continue
+                    excluded_paths.add(line)
 
     # Handle output redirection, if requested and relevant.
     options.output_fp = sys.stdout
     if options.output_file:
         if not options.show_cmd:
             options.show_output = True
         try:
             options.output_fp = open(options.output_file, 'w')