OLD | NEW |
(Empty) | |
| 1 # Copyright 2011 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 import test |
| 29 import os |
| 30 from os.path import join, dirname, exists |
| 31 import platform |
| 32 import utils |
| 33 |
| 34 |
| 35 class PreparserTestCase(test.TestCase): |
| 36 |
| 37 def __init__(self, root, path, executable, mode, context): |
| 38 super(PreparserTestCase, self).__init__(context, path, mode) |
| 39 self.executable = executable |
| 40 self.root = root |
| 41 |
| 42 def GetLabel(self): |
| 43 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) |
| 44 |
| 45 def GetName(self): |
| 46 return self.path[-1] |
| 47 |
| 48 def BuildCommand(self, path): |
| 49 testfile = join(self.root, self.GetName()) + ".js" |
| 50 result = [self.executable, testfile] |
| 51 return result |
| 52 |
| 53 def GetCommand(self): |
| 54 return self.BuildCommand(self.path) |
| 55 |
| 56 def Run(self): |
| 57 return test.TestCase.Run(self) |
| 58 |
| 59 |
| 60 class PreparserTestConfiguration(test.TestConfiguration): |
| 61 |
| 62 def __init__(self, context, root): |
| 63 super(PreparserTestConfiguration, self).__init__(context, root) |
| 64 |
| 65 def GetBuildRequirements(self): |
| 66 return ['preparser'] |
| 67 |
| 68 def ListTests(self, current_path, path, mode, variant_flags): |
| 69 executable = join('obj', 'preparser', mode, 'preparser') |
| 70 if utils.IsWindows(): |
| 71 executable += '.exe' |
| 72 executable = join(self.context.buildspace, executable) |
| 73 # Find all .js files in tests/preparser directory. |
| 74 filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")] |
| 75 filenames.sort() |
| 76 result = [] |
| 77 for file in filenames: |
| 78 result.append(PreparserTestCase(self.root, |
| 79 current_path + [file], executable, |
| 80 mode, self.context)) |
| 81 return result |
| 82 |
| 83 def GetTestStatus(self, sections, defs): |
| 84 status_file = join(self.root, 'preparser.status') |
| 85 if exists(status_file): |
| 86 test.ReadConfigurationInto(status_file, sections, defs) |
| 87 |
| 88 |
| 89 def GetConfiguration(context, root): |
| 90 return PreparserTestConfiguration(context, root) |
OLD | NEW |