]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Support automatically opening test HTML in browser
authorSolly Ross <sross@redhat.com>
Tue, 3 Jun 2014 15:02:27 +0000 (11:02 -0400)
committerSolly Ross <sross@redhat.com>
Tue, 3 Jun 2014 15:17:29 +0000 (11:17 -0400)
When using the '-g' option with run_from_console.js, you can
now pass the '-o' option to automatically open the generated
HTML file in your default browser.  This relies on the 'open'
NPM module.

tests/run_from_console.js

index 7525c8b47000659ec278a330984c417053d9bc45..a5ce635caf777ea31975645863fc3388e7adeb37 100755 (executable)
@@ -15,7 +15,8 @@ program
   .option('-c, --color', 'Explicitly enable color (default is to use color when not outputting to a pipe)')
   .option('-i, --auto-inject <includefiles>', 'Treat the test list as a set of mocha JS files, and automatically generate HTML files with which to test test.  \'includefiles\' should be a comma-separated list of paths to javascript files to include in each of the generated HTML files', make_list, null)
   .option('-p, --provider <name>', 'Use the given provider (defaults to "casper").  Currently, may be "casper" or "zombie"', 'casper')
-  .option('-g, --generate-html', 'Instead of running the tests, just return the path to the generated HTML file, then wait for user interaction to exit (should be used with .js tests)')
+  .option('-g, --generate-html', 'Instead of running the tests, just return the path to the generated HTML file, then wait for user interaction to exit (should be used with .js tests).')
+  .option('-o, --open-in-browser', 'Open the generated HTML files in a web browser using the "open" module (must be used with the "-g"/"--generate-html" option).')
   .option('-o, --output-html', 'Instead of running the tests, just output the generated HTML source to STDOUT (should be used with .js tests)')
   .option('-d, --debug', 'Show debug output (the "console" event) from the provider')
   .parse(process.argv);
@@ -119,6 +120,11 @@ if (program.outputHtml) {
 }
 
 if (program.generateHtml) {
+  var open_browser;
+  if (program.openInBrowser) {
+    open_browser = require('open');
+  }
+
   file_paths.forEach(function(path, path_ind) {
     cursor
       .bold()
@@ -127,6 +133,10 @@ if (program.generateHtml) {
       .reset()
       .write(path)
       .write("\n");
+
+    if (program.openInBrowser) {
+      open_browser(path);
+    }
   });
   console.log('');
 }