diff options
author | Mike Pennisi <mike@mikepennisi.com> | 2015-06-08 15:35:16 -0400 |
---|---|---|
committer | Mike Pennisi <mike@mikepennisi.com> | 2015-07-07 13:18:55 -0400 |
commit | ab7617deddec3025848ac69ebdea6389b94e9a92 (patch) | |
tree | ed465dd578cc92a23991ffe2aa0399649074fa56 /tools/packaging | |
parent | c6ac3908682247326e098c5834537c5a279e9a60 (diff) | |
download | qtdeclarative-testsuites-ab7617deddec3025848ac69ebdea6389b94e9a92.tar.gz |
Implement `raw` flag
Some tests involving the directive prologue are invalidated by source
text transformations that insert executable code in the beginning of the
script. Implement a `raw` flag that allows these tests to opt-out of
this transformation. Update the relevant tests to use this flag (and
remove references to globals only available when code is injected).
Update the Python runner accordingly:
- Do not run tests marked as "raw" in strict mode
- Reject invalid test configurations
Update the browser runner accordingly:
- Do not modify the script body of tests marked as "raw"
Diffstat (limited to 'tools/packaging')
-rwxr-xr-x | tools/packaging/test262.py | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/tools/packaging/test262.py b/tools/packaging/test262.py index 5a606bb18..921360a05 100755 --- a/tools/packaging/test262.py +++ b/tools/packaging/test262.py @@ -243,6 +243,8 @@ class TestCase(object): testRecord.pop("commentary", None) # do not throw if missing self.testRecord = testRecord; + self.validate() + def NegativeMatch(self, stderr): neg = re.compile(self.GetNegative()) return re.search(neg, stderr) @@ -269,7 +271,10 @@ class TestCase(object): return 'onlyStrict' in self.testRecord def IsNoStrict(self): - return 'noStrict' in self.testRecord + return 'noStrict' in self.testRecord or self.IsRaw() + + def IsRaw(self): + return 'raw' in self.testRecord def IsAsyncTest(self): return '$DONE' in self.test @@ -282,20 +287,10 @@ class TestCase(object): def GetAdditionalIncludes(self): return '\n'.join([self.suite.GetInclude(include) for include in self.GetIncludeList()]) - def WrapTest(self, command): - if "cscript" not in command: - return self.test + def GetSource(self): + if self.IsRaw(): + return self.test - return """ -try { -""" + self.test + """ -} catch(e) { - $ERROR(e.message); -} -""" - - def GetSource(self, command_template): - # "var testDescrip = " + str(self.testRecord) + ';\n\n' + \ source = self.suite.GetInclude("sta.js") + \ self.suite.GetInclude("cth.js") + \ self.suite.GetInclude("assert.js") @@ -307,7 +302,7 @@ try { source = source + \ self.GetAdditionalIncludes() + \ - self.WrapTest(command_template) + '\n' + self.test + '\n' if self.strict_mode: source = '"use strict";\nvar strict_mode = true;\n' + source @@ -347,7 +342,7 @@ try { return (code, out, err) def RunTestIn(self, command_template, tmp): - tmp.Write(self.GetSource(command_template)) + tmp.Write(self.GetSource()) tmp.Close() command = self.InstantiateTemplate(command_template, { 'path': tmp.name @@ -364,8 +359,23 @@ try { return result def Print(self): - print self.GetSource("") - + print self.GetSource() + + def validate(self): + flags = self.testRecord.get("flags") + + if not flags: + return + + if 'raw' in flags: + if 'noStrict' in flags: + raise TypeError("The `raw` flag implies the `noStrict` flag") + elif 'onlyStrict' in flags: + raise TypeError( + "The `raw` flag is incompatible with the `onlyStrict` flag") + elif len(self.GetIncludeList()) > 0: + raise TypeError( + "The `raw` flag is incompatible with the `includes` tag") class ProgressIndicator(object): |