Browse Source

Use v8's test runner

v0.7.4-release
Ryan 16 years ago
parent
commit
3fed1a0954
  1. 15
      configure
  2. 0
      test/mjsunit/fixtures/a.js
  3. 0
      test/mjsunit/fixtures/b/c.js
  4. 0
      test/mjsunit/fixtures/b/d.js
  5. 0
      test/mjsunit/fixtures/x.txt
  6. 0
      test/mjsunit/mjsunit.js
  7. 0
      test/mjsunit/test-file-cat-noexist.js
  8. 0
      test/mjsunit/test-file-open.js
  9. 0
      test/mjsunit/test-http-cat.js
  10. 0
      test/mjsunit/test-http-client-race.js
  11. 0
      test/mjsunit/test-http-proxy.js
  12. 0
      test/mjsunit/test-http-server.js
  13. 0
      test/mjsunit/test-http.js
  14. 0
      test/mjsunit/test-module-loading.js
  15. 0
      test/mjsunit/test-node-cat.js
  16. 0
      test/mjsunit/test-process-kill.js
  17. 0
      test/mjsunit/test-process-simple.js
  18. 0
      test/mjsunit/test-reconnecting-socket.js
  19. 0
      test/mjsunit/test-remote-module-loading.js
  20. 0
      test/mjsunit/test-tcp-pingpong.js
  21. 0
      test/mjsunit/test-timers.js
  22. 105
      test/mjsunit/testcfg.py
  23. 218
      tools/jsmin.py
  24. 1
      tools/jsmin.py
  25. 1
      tools/run-valgrind.py
  26. 1343
      tools/test.py
  27. 1
      tools/utils.py

15
configure

@ -94,18 +94,11 @@ uninstall:
$WAF uninstall ; \\ $WAF uninstall ; \\
fi; fi;
FAIL=python -c 'print("\033[1;31mFAIL\033[m")'
PASS=python -c 'print("\033[1;32mPASS\033[m")'
test: all test: all
@for i in test/test*.js; do \\ python tools/test.py --mode=release
echo "default \$\$i: "; \\
build/default/node \$\$i && \$(PASS) || \$(FAIL); \\ test-debug: all
if [ -e build/debug/node ]; then \\ python tools/test.py --mode=debug
echo "debug \$\$i: "; \\
build/debug/node \$\$i && \$(PASS) || \$(FAIL); \\
fi; \\
done
clean: clean:
@$WAF clean @$WAF clean

0
test/fixtures/a.js → test/mjsunit/fixtures/a.js

0
test/fixtures/b/c.js → test/mjsunit/fixtures/b/c.js

0
test/fixtures/b/d.js → test/mjsunit/fixtures/b/d.js

0
test/fixtures/x.txt → test/mjsunit/fixtures/x.txt

0
test/mjsunit.js → test/mjsunit/mjsunit.js

0
test/test-file-cat-noexist.js → test/mjsunit/test-file-cat-noexist.js

0
test/test-file-open.js → test/mjsunit/test-file-open.js

0
test/test-http-cat.js → test/mjsunit/test-http-cat.js

0
test/test-http-client-race.js → test/mjsunit/test-http-client-race.js

0
test/test-http-proxy.js → test/mjsunit/test-http-proxy.js

0
test/test-http-server.js → test/mjsunit/test-http-server.js

0
test/test-http.js → test/mjsunit/test-http.js

0
test/test-module-loading.js → test/mjsunit/test-module-loading.js

0
test/test-node-cat.js → test/mjsunit/test-node-cat.js

0
test/test-process-kill.js → test/mjsunit/test-process-kill.js

0
test/test-process-simple.js → test/mjsunit/test-process-simple.js

0
test/test-reconnecting-socket.js → test/mjsunit/test-reconnecting-socket.js

0
test/test-remote-module-loading.js → test/mjsunit/test-remote-module-loading.js

0
test/test-tcp-pingpong.js → test/mjsunit/test-tcp-pingpong.js

0
test/test-timers.js → test/mjsunit/test-timers.js

105
test/mjsunit/testcfg.py

@ -0,0 +1,105 @@
# Copyright 2008 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import test
import os
from os.path import join, dirname, exists
import re
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
class MjsunitTestCase(test.TestCase):
def __init__(self, path, file, mode, context, config):
super(MjsunitTestCase, self).__init__(context, path)
self.file = file
self.config = config
self.mode = mode
def GetLabel(self):
return "%s %s" % (self.mode, self.GetName())
def GetName(self):
return self.path[-1]
def GetCommand(self):
result = [self.config.context.GetVm(self.mode)]
source = open(self.file).read()
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
result += flags_match.group(1).strip().split()
files_match = FILES_PATTERN.search(source);
additional_files = []
if files_match:
additional_files += files_match.group(1).strip().split()
for a_file in additional_files:
result.append(join(dirname(self.config.root), '..', a_file))
result += [self.file]
return result
def GetSource(self):
return open(self.file).read()
class MjsunitTestConfiguration(test.TestConfiguration):
def __init__(self, context, root):
super(MjsunitTestConfiguration, self).__init__(context, root)
def Ls(self, path):
def SelectTest(name):
return name.endswith('.js') and name != 'mjsunit.js'
return [f[:-3] for f in os.listdir(path) if SelectTest(f)]
def ListTests(self, current_path, path, mode):
mjsunit = [current_path + [t] for t in self.Ls(self.root)]
#regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'regress'))]
#bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))]
#tools = [current_path + ['tools', t] for t in self.Ls(join(self.root, 'tools'))]
all_tests = mjsunit # + regress + bugs + tools
result = []
for test in all_tests:
if self.Contains(path, test):
file_path = join(self.root, reduce(join, test[1:], "") + ".js")
result.append(MjsunitTestCase(test, file_path, mode, self.context, self))
return result
def GetBuildRequirements(self):
return ['sample', 'sample=shell']
def GetTestStatus(self, sections, defs):
status_file = join(self.root, 'mjsunit.status')
if exists(status_file):
test.ReadConfigurationInto(status_file, sections, defs)
def GetConfiguration(context, root):
return MjsunitTestConfiguration(context, root)

218
tools/jsmin.py

@ -1,218 +0,0 @@
#!/usr/bin/python
# This code is original from jsmin by Douglas Crockford, it was translated to
# Python by Baruch Even. The original code had the following copyright and
# license.
#
# /* jsmin.c
# 2007-05-22
#
# Copyright (c) 2002 Douglas Crockford (www.crockford.com)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# The Software shall be used for Good, not Evil.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# */
from StringIO import StringIO
def jsmin(js):
ins = StringIO(js)
outs = StringIO()
JavascriptMinify().minify(ins, outs)
str = outs.getvalue()
if len(str) > 0 and str[0] == '\n':
str = str[1:]
return str
def isAlphanum(c):
"""return true if the character is a letter, digit, underscore,
dollar sign, or non-ASCII character.
"""
return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or
(c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126));
class UnterminatedComment(Exception):
pass
class UnterminatedStringLiteral(Exception):
pass
class UnterminatedRegularExpression(Exception):
pass
class JavascriptMinify(object):
def _outA(self):
self.outstream.write(self.theA)
def _outB(self):
self.outstream.write(self.theB)
def _get(self):
"""return the next character from stdin. Watch out for lookahead. If
the character is a control character, translate it to a space or
linefeed.
"""
c = self.theLookahead
self.theLookahead = None
if c == None:
c = self.instream.read(1)
if c >= ' ' or c == '\n':
return c
if c == '': # EOF
return '\000'
if c == '\r':
return '\n'
return ' '
def _peek(self):
self.theLookahead = self._get()
return self.theLookahead
def _next(self):
"""get the next character, excluding comments. peek() is used to see
if an unescaped '/' is followed by a '/' or '*'.
"""
c = self._get()
if c == '/' and self.theA != '\\':
p = self._peek()
if p == '/':
c = self._get()
while c > '\n':
c = self._get()
return c
if p == '*':
c = self._get()
while 1:
c = self._get()
if c == '*':
if self._peek() == '/':
self._get()
return ' '
if c == '\000':
raise UnterminatedComment()
return c
def _action(self, action):
"""do something! What you do is determined by the argument:
1 Output A. Copy B to A. Get the next B.
2 Copy B to A. Get the next B. (Delete A).
3 Get the next B. (Delete B).
action treats a string as a single character. Wow!
action recognizes a regular expression if it is preceded by ( or , or =.
"""
if action <= 1:
self._outA()
if action <= 2:
self.theA = self.theB
if self.theA == "'" or self.theA == '"':
while 1:
self._outA()
self.theA = self._get()
if self.theA == self.theB:
break
if self.theA <= '\n':
raise UnterminatedStringLiteral()
if self.theA == '\\':
self._outA()
self.theA = self._get()
if action <= 3:
self.theB = self._next()
if self.theB == '/' and (self.theA == '(' or self.theA == ',' or
self.theA == '=' or self.theA == ':' or
self.theA == '[' or self.theA == '?' or
self.theA == '!' or self.theA == '&' or
self.theA == '|' or self.theA == ';' or
self.theA == '{' or self.theA == '}' or
self.theA == '\n'):
self._outA()
self._outB()
while 1:
self.theA = self._get()
if self.theA == '/':
break
elif self.theA == '\\':
self._outA()
self.theA = self._get()
elif self.theA <= '\n':
raise UnterminatedRegularExpression()
self._outA()
self.theB = self._next()
def _jsmin(self):
"""Copy the input to the output, deleting the characters which are
insignificant to JavaScript. Comments will be removed. Tabs will be
replaced with spaces. Carriage returns will be replaced with linefeeds.
Most spaces and linefeeds will be removed.
"""
self.theA = '\n'
self._action(3)
while self.theA != '\000':
if self.theA == ' ':
if isAlphanum(self.theB):
self._action(1)
else:
self._action(2)
elif self.theA == '\n':
if self.theB in ['{', '[', '(', '+', '-']:
self._action(1)
elif self.theB == ' ':
self._action(3)
else:
if isAlphanum(self.theB):
self._action(1)
else:
self._action(2)
else:
if self.theB == ' ':
if isAlphanum(self.theA):
self._action(1)
else:
self._action(3)
elif self.theB == '\n':
if self.theA in ['}', ']', ')', '+', '-', '"', '\'']:
self._action(1)
else:
if isAlphanum(self.theA):
self._action(1)
else:
self._action(3)
else:
self._action(1)
def minify(self, instream, outstream):
self.instream = instream
self.outstream = outstream
self.theA = '\n'
self.theB = None
self.theLookahead = None
self._jsmin()
self.instream.close()
if __name__ == '__main__':
import sys
jsm = JavascriptMinify()
jsm.minify(sys.stdin, sys.stdout)

1
tools/jsmin.py

@ -0,0 +1 @@
../deps/v8/tools/jsmin.py

1
tools/run-valgrind.py

@ -0,0 +1 @@
../deps/v8/tools/run-valgrind.py

1343
tools/test.py

File diff suppressed because it is too large

1
tools/utils.py

@ -0,0 +1 @@
../deps/v8/tools/utils.py
Loading…
Cancel
Save