[javascriptlint-commit] SF.net SVN: javascriptlint:[247] trunk
Status: Beta
Brought to you by:
matthiasmiller
|
From: <mat...@us...> - 2009-10-03 09:53:20
|
Revision: 247
http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=247&view=rev
Author: matthiasmiller
Date: 2009-10-03 09:07:39 +0000 (Sat, 03 Oct 2009)
Log Message:
-----------
Make test.py a standalone script.
Modified Paths:
--------------
trunk/jsl.py
trunk/setup.py
trunk/test.py
Property Changed:
----------------
trunk/test.py
Modified: trunk/jsl.py
===================================================================
--- trunk/jsl.py 2009-08-27 16:52:43 UTC (rev 246)
+++ trunk/jsl.py 2009-10-03 09:07:39 UTC (rev 247)
@@ -12,43 +12,18 @@
except ImportError:
pass
else:
- sys.path.append(setup.get_lib_path())
+ setup.addsearchpath()
import pyjsl.conf
import pyjsl.htmlparse
import pyjsl.jsparse
import pyjsl.util
-import test
_lint_results = {
'warnings': 0,
'errors': 0
}
-def get_test_files():
- # Get a list of test files.
- dir_ = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tests')
-
- all_files = []
- for root, dirs, files in os.walk(dir_):
- all_files += [os.path.join(dir_, root, file) for file in files]
- if '.svn' in dirs:
- dirs.remove('.svn')
- # TODO
- if 'conf' in dirs:
- dirs.remove('conf')
- all_files.sort()
- return all_files
-
-def run_tests():
- for file in get_test_files():
- ext = os.path.splitext(file)[1]
- if ext in ('.htm', '.html', '.js'):
- try:
- test.run(file)
- except test.TestError, error:
- print error
-
def _dump(paths):
for path in paths:
script = pyjsl.util.readfile(path)
@@ -102,8 +77,6 @@
add = parser.add_option
add("--conf", dest="conf", metavar="CONF",
help="set the conf file")
- add("-t", "--test", dest="test", action="store_true", default=False,
- help="run the javascript tests")
add("--profile", dest="profile", action="store_true", default=False,
help="turn on hotshot profiling")
add("--dump", dest="dump", action="store_true", default=False,
@@ -137,9 +110,6 @@
runner = unittest.TextTestRunner(verbosity=options.verbosity)
runner.run(suite)
- if options.test:
- profile_func(run_tests)
-
paths = []
for recurse, path in conf['paths']:
paths.extend(_resolve_paths(path, recurse))
Modified: trunk/setup.py
===================================================================
--- trunk/setup.py 2009-08-27 16:52:43 UTC (rev 246)
+++ trunk/setup.py 2009-10-03 09:07:39 UTC (rev 247)
@@ -2,6 +2,7 @@
# vim: ts=4 sw=4 expandtab
from distutils.core import setup, Extension
import os
+import sys
# Add the bin directory to the module search path
def get_lib_path():
@@ -12,6 +13,9 @@
build.finalize_options()
return os.path.join(os.path.dirname(__file__), build.build_platlib)
+def addsearchpath():
+ sys.path.append(get_lib_path())
+
if __name__ == '__main__':
if os.name == 'nt':
library = 'js32'
Modified: trunk/test.py
===================================================================
--- trunk/test.py 2009-08-27 16:52:43 UTC (rev 246)
+++ trunk/test.py 2009-10-03 09:07:39 UTC (rev 247)
@@ -1,6 +1,16 @@
+#!/usr/bin/python
# vim: ts=4 sw=4 expandtab
+import os
import re
+import sys
+try:
+ import setup
+except ImportError:
+ pass
+else:
+ setup.addsearchpath()
+
import pyjsl.conf
import pyjsl.lint
@@ -36,7 +46,7 @@
warnings.append((i, warning))
return warnings
-def run(path):
+def _testfile(path):
# Parse the script and find the expected warnings.
script = open(path).read()
expected_warnings = _get_expected_warnings(script)
@@ -70,3 +80,33 @@
if errors:
raise TestError, '\n'.join(errors)
+def _get_test_files():
+ # Get a list of test files.
+ dir_ = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tests')
+
+ all_files = []
+ for root, dirs, files in os.walk(dir_):
+ all_files += [os.path.join(dir_, root, file) for file in files]
+ if '.svn' in dirs:
+ dirs.remove('.svn')
+ # TODO
+ if 'conf' in dirs:
+ dirs.remove('conf')
+ all_files.sort()
+ return all_files
+
+def main():
+ haderrors = False
+ for file in _get_test_files():
+ ext = os.path.splitext(file)[1]
+ if ext in ('.htm', '.html', '.js'):
+ try:
+ _testfile(file)
+ except test.TestError, error:
+ haderrors = True
+ print error
+ sys.exit(haderrors)
+
+if __name__ == '__main__':
+ main()
+
Property changes on: trunk/test.py
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|