summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorscr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-01 20:46:17 +0000
committerscr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-01 20:46:17 +0000
commit982899490c820869b822b7064a5bf2f902252e63 (patch)
tree22ba06494e97a7e2b71d9dc7d99fa509f8f14ae7 /tools
parent643e00999f7a57323f696e712534665f1931d865 (diff)
downloadchromium_src-982899490c820869b822b7064a5bf2f902252e63.zip
chromium_src-982899490c820869b822b7064a5bf2f902252e63.tar.gz
chromium_src-982899490c820869b822b7064a5bf2f902252e63.tar.bz2
Support automatic javascript test registry in gtest when creating WebUI tests.
The goal was to support something as simple as the following, where the tests in the javascript files would be 1st class GTESTs, supporting FLAKY_, DISABLED_, etc, and registered at linker_initialization time. WEB_UI_BROWSER_TEST_JS(WebUIBrowserTest, TestJSPass, FILE_PATH_LITERAL("sample_passing.js")) { ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); } This solution ended up being fairly fragile, and I ended up with a script to parse javascript (with the help of v8_shell) and generate an includable ...-inl.h file with the following for every test in the .js file specified in the |rules| section of tools/js2webui.py IN_PROC_BROWSER_TEST_F(WebUIBrowserTestPass, testHelper) { AddLibrary(FilePath(FILE_PATH_LITERAL("sample_pass.js"))); ASSERT_TRUE(RunJavascriptTest("testHelper")); } http://www.chromium.org/Home/domui-testing BUG=82437 R=estade@chromium.org,jhawkins@chromium.org TEST=browser_tests --gtest_filter=WebUIBrowserTest* Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=89453 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=89605 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=89626 Review URL: http://codereview.chromium.org/7087014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/gypv8sh.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/gypv8sh.py b/tools/gypv8sh.py
new file mode 100644
index 0000000..ed47649
--- /dev/null
+++ b/tools/gypv8sh.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""This script is used by chrome_tests.gypi's js2webui action to maintain the
+argument lists and to generate inlinable tests.
+
+Usage:
+ python tools/gypv8sh.py v8_shell js2webui.js inputfile outputfile
+"""
+
+try:
+ import json
+except ImportError:
+ import simplejson as json
+import optparse
+import os
+import subprocess
+import sys
+
+def main ():
+ parser = optparse.OptionParser()
+ parser.set_usage("%prog v8_shell js2webui.js inputfile outputfile")
+ parser.add_option('-v', '--verbose', action='store_true')
+ parser.add_option('-n', '--impotent', action='store_true',
+ help="don't execute; just print (as if verbose)")
+ (opts, args) = parser.parse_args()
+
+ if len(args) != 4:
+ parser.error('all arguments are required.')
+ v8_shell, js2webui, inputfile, outputfile = args
+ arguments = [js2webui, inputfile, os.path.basename(inputfile), outputfile]
+ cmd = [v8_shell, '-e', "arguments=" + json.dumps(arguments), js2webui]
+ if opts.verbose or opts.impotent:
+ print cmd
+ if not opts.impotent:
+ try:
+ subprocess.check_call(cmd, stdout=open(outputfile,'w'))
+ except Exception, ex:
+ print ex
+ os.remove(outputfile)
+ sys.exit(1)
+
+if __name__ == '__main__':
+ sys.exit(main())