OLD | NEW |
(Empty) | |
| 1 # Copyright 2008 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are |
| 4 # met: |
| 5 # |
| 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided |
| 11 # with the distribution. |
| 12 # * Neither the name of Google Inc. nor the names of its |
| 13 # contributors may be used to endorse or promote products derived |
| 14 # from this software without specific prior written permission. |
| 15 # |
| 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 |
| 29 import test |
| 30 import os |
| 31 from os.path import join, exists |
| 32 |
| 33 |
| 34 HARNESS_FILES = ['sth.js'] |
| 35 |
| 36 |
| 37 class ES5ConformTestCase(test.TestCase): |
| 38 |
| 39 def __init__(self, filename, path, context, root, mode, framework): |
| 40 super(ES5ConformTestCase, self).__init__(context, path) |
| 41 self.filename = filename |
| 42 self.mode = mode |
| 43 self.framework = framework |
| 44 self.root = root |
| 45 |
| 46 def IsNegative(self): |
| 47 return self.filename.endswith('-n.js') |
| 48 |
| 49 def GetLabel(self): |
| 50 return "%s es5conform %s" % (self.mode, self.GetName()) |
| 51 |
| 52 def IsFailureOutput(self, output): |
| 53 if output.exit_code != 0: |
| 54 return True |
| 55 return 'FAILED!' in output.stdout |
| 56 |
| 57 def GetCommand(self): |
| 58 result = [self.context.GetVm(self.mode)] |
| 59 result += ['-e', 'var window = this'] |
| 60 result += self.framework |
| 61 result.append(self.filename) |
| 62 result += ['-e', 'ES5Harness.startTesting()'] |
| 63 return result |
| 64 |
| 65 def GetName(self): |
| 66 return self.path[-1] |
| 67 |
| 68 def GetSource(self): |
| 69 return open(self.filename).read() |
| 70 |
| 71 |
| 72 class ES5ConformTestConfiguration(test.TestConfiguration): |
| 73 |
| 74 def __init__(self, context, root): |
| 75 super(ES5ConformTestConfiguration, self).__init__(context, root) |
| 76 |
| 77 def ListTests(self, current_path, path, mode): |
| 78 tests = [] |
| 79 current_root = join(self.root, 'data', 'TestCases') |
| 80 harness = [] |
| 81 harness += [join(self.root, 'data', 'SimpleTestHarness', f) for f in HARNESS
_FILES] |
| 82 harness += [join(self.root, 'harness-adapt.js')] |
| 83 for root, dirs, files in os.walk(current_root): |
| 84 for dotted in [x for x in dirs if x.startswith('.')]: |
| 85 dirs.remove(dotted) |
| 86 root_path = root[len(self.root):].split(os.path.sep) |
| 87 root_path = current_path + [x for x in root_path if x] |
| 88 for file in files: |
| 89 if file.endswith('.js'): |
| 90 full_path = root_path + [file[:-3]] |
| 91 full_path = [x for x in full_path if not (x in ['data', 'TestCases'])] |
| 92 if self.Contains(path, full_path): |
| 93 test = ES5ConformTestCase(join(root, file), full_path, self.context, |
| 94 self.root, mode, harness) |
| 95 tests.append(test) |
| 96 return tests |
| 97 |
| 98 def GetBuildRequirements(self): |
| 99 return ['sample', 'sample=shell'] |
| 100 |
| 101 def GetTestStatus(self, sections, defs): |
| 102 status_file = join(self.root, 'es5conform.status') |
| 103 if exists(status_file): |
| 104 test.ReadConfigurationInto(status_file, sections, defs) |
| 105 |
| 106 |
| 107 def GetConfiguration(context, root): |
| 108 return ES5ConformTestConfiguration(context, root) |
OLD | NEW |