author | Tooru Fujisawa <arai_a@mac.com> |
Wed, 28 Jan 2015 05:19:30 +0900 | |
changeset 226057 | 63e93ddb740f2abaf38f63f5ff40f15e59248816 |
parent 226056 | e79c310fc6594fa66d9a760e7c925d366b8d359a |
child 226058 | 3de67cecd18d3765b1819dedd9f7db2b67d09849 |
push id | 54752 |
push user | arai_a@mac.com |
push date | Tue, 27 Jan 2015 20:20:03 +0000 |
treeherder | mozilla-inbound@ce00599c23e2 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | terrence |
bugs | 1125512 |
milestone | 38.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
|
--- a/js/src/tests/lib/manifest.py +++ b/js/src/tests/lib/manifest.py @@ -26,23 +26,24 @@ class XULInfo: self.os = os self.isdebug = isdebug self.browserIsRemote = False def as_js(self): """Return JS that when executed sets up variables so that JS expression predicates on XUL build info evaluate properly.""" - return ('var xulRuntime = { OS: "%s", XPCOMABI: "%s", shell: true };' + - 'var isDebugBuild=%s; var Android=%s; var browserIsRemote=%s') % ( - self.os, - self.abi, - str(self.isdebug).lower(), - str(self.os == "Android").lower(), - str(self.browserIsRemote).lower()) + return ('var xulRuntime = {{ OS: "{}", XPCOMABI: "{}", shell: true }};' + 'var isDebugBuild={}; var Android={}; ' + 'var browserIsRemote={}'.format( + self.os, + self.abi, + str(self.isdebug).lower(), + str(self.os == "Android").lower(), + str(self.browserIsRemote).lower())) @classmethod def create(cls, jsdir): """Create a XULInfo based on the current platform's characteristics.""" # Our strategy is to find the autoconf.mk generated for the build and # read the values from there. @@ -52,23 +53,23 @@ class XULInfo: path = None for dir in dirs: _path = os.path.join(dir, 'config/autoconf.mk') if os.path.isfile(_path): path = _path break if path == None: - print ("Can't find config/autoconf.mk on a directory containing the JS shell" - " (searched from %s)") % jsdir + print("Can't find config/autoconf.mk on a directory containing" + " the JS shell (searched from {})".format(jsdir)) sys.exit(1) # Read the values. val_re = re.compile(r'(TARGET_XPCOM_ABI|OS_TARGET|MOZ_DEBUG)\s*=\s*(.*)') - kw = { 'isdebug': False } + kw = {'isdebug': False} for line in open(path): m = val_re.match(line) if m: key, val = m.groups() val = val.rstrip() if key == 'TARGET_XPCOM_ABI': kw['abi'] = val if key == 'OS_TARGET': @@ -83,27 +84,31 @@ class XULInfoTester: self.js_bin = js_bin # Maps JS expr to evaluation result. self.cache = {} def test(self, cond): """Test a XUL predicate condition against this local info.""" ans = self.cache.get(cond, None) if ans is None: - cmd = [ self.js_bin, '-e', self.js_prolog, '-e', 'print(!!(%s))'%cond ] + cmd = [ + self.js_bin, + '-e', self.js_prolog, + '-e', 'print(!!({}))'.format(cond) + ] p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) out, err = p.communicate() if out in ('true\n', 'true\r\n'): ans = True elif out in ('false\n', 'false\r\n'): ans = False else: - raise Exception(("Failed to test XUL condition %r;" - + " output was %r, stderr was %r") - % (cond, out, err)) + raise Exception("Failed to test XUL condition {!r};" + " output was {!r}, stderr was {!r}".format( + cond, out, err)) self.cache[cond] = ans return ans class NullXULInfoTester: """Can be used to parse manifests without a JS shell.""" def test(self, cond): return False @@ -143,17 +148,18 @@ def _parse_one(testcase, xul_tester): testcase.slow = True pos += 1 elif parts[pos] == 'silentfail': # silentfails use tons of memory, and Darwin doesn't support ulimit. if xul_tester.test("xulRuntime.OS == 'Darwin'"): testcase.expect = testcase.enable = False pos += 1 else: - print('warning: invalid manifest line element "%s"'%parts[pos]) + print('warning: invalid manifest line element "{}"'.format( + parts[pos])) pos += 1 def _build_manifest_script_entry(script_name, test): line = [] if test.terms: line.append(test.terms) line.append("script") line.append(script_name) @@ -203,18 +209,18 @@ def _emit_manifest_at(location, relative line = _build_manifest_script_entry(k, test_list[0]) manifest.append(line) # Always present our manifest in sorted order. manifest.sort() # If we have tests, we have to set the url-prefix so reftest can find them. if numTestFiles > 0: - manifest = (["url-prefix %sjsreftest.html?test=%s/" % ('../' * depth, relative)] - + manifest) + manifest = ["url-prefix {}jsreftest.html?test={}/".format( + '../' * depth, relative)] + manifest fp = open(filename, 'w') try: fp.write('\n'.join(manifest) + '\n') finally: fp.close() def make_manifests(location, test_list): @@ -274,31 +280,34 @@ def _parse_external_manifest(filename, r manifest_re = re.compile(r'^\s*(.*)\s+(include|script)\s+(\S+)$') for line in fp: line, _, comment = line.partition('#') line = line.strip() if not line: continue matches = manifest_re.match(line) if not matches: - print('warning: unrecognized line in jstests.list: {0}'.format(line)) + print('warning: unrecognized line in jstests.list:' + ' {0}'.format(line)) continue path = os.path.normpath(os.path.join(relpath, matches.group(3))) if matches.group(2) == 'include': # The manifest spec wants a reference to another manifest here, # but we need just the directory. We do need the trailing # separator so we don't accidentally match other paths of which # this one is a prefix. assert(path.endswith('jstests.list')) path = path[:-len('jstests.list')] - entries.append({'path': path, 'terms': matches.group(1), 'comment': comment.strip()}) + entries.append({'path': path, 'terms': matches.group(1), + 'comment': comment.strip()}) - # if one directory name is a prefix of another, we want the shorter one first + # if one directory name is a prefix of another, we want the shorter one + # first entries.sort(key=lambda x: x["path"]) return entries def _apply_external_manifests(filename, testcase, entries, xul_tester): for entry in entries: if filename.startswith(entry["path"]): # The reftest spec would require combining the terms (failure types) # that may already be defined in the test case with the terms @@ -309,17 +318,17 @@ def _apply_external_manifests(filename, # conditions. # At this point, we use external manifests only for test cases # that can't have their own failure type comments, so we simply # use the terms for the most specific path. testcase.terms = entry["terms"] testcase.comment = entry["comment"] _parse_one(testcase, xul_tester) -def load(location, requested_paths, excluded_paths, xul_tester, reldir = ''): +def load(location, requested_paths, excluded_paths, xul_tester, reldir=''): """ Locates all tests by walking the filesystem starting at |location|. Uses xul_tester to evaluate any test conditions in the test header. Failure type and comment for a test case can come from - an external manifest entry for the test case, - an external manifest entry for a containing directory, - most commonly: the header of the test case itself. """ @@ -359,12 +368,13 @@ def load(location, requested_paths, excl continue # Skip empty files. statbuf = os.stat(fullpath) if statbuf.st_size == 0: continue testcase = TestCase(os.path.join(reldir, filename)) - _apply_external_manifests(filename, testcase, externalManifestEntries, xul_tester) + _apply_external_manifests(filename, testcase, externalManifestEntries, + xul_tester) _parse_test_header(fullpath, testcase, xul_tester) tests.append(testcase) return tests