From 2323945cebe74e7ca1f3897fcb5e7a5aed5fc80f Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Mon, 3 Jun 2013 15:39:11 -0400 Subject: [PATCH] Add --verbose to ./test.sh and phantom-driver.js --- phantom-driver.js | 14 ++++++++++---- test.sh | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/phantom-driver.js b/phantom-driver.js index 9b98fdf..a782100 100644 --- a/phantom-driver.js +++ b/phantom-driver.js @@ -22,10 +22,16 @@ page.open(url, function(status) { } var testCase, test; - if (phantom.args.length == 1) { - var parts = phantom.args[0].split('.'); + var verbose = false; + var optIdx = 0; + if (phantom.args.length > 0 && phantom.args[0] === "--verbose") { + verbose = true; + optIdx = 1; + } + if (phantom.args.length == optIdx + 1) { + var parts = phantom.args[optIdx].split('.'); if (2 != parts.length) { - console.warn('Usage: phantomjs phantom-driver.js [testCase.test]'); + console.warn('Usage: phantomjs phantom-driver.js [--verbose] [testCase.test]'); phantom.exit(); } testCase = parts[0]; @@ -39,7 +45,7 @@ page.open(url, function(status) { } else if (msg.substr(0, 'Running'.length) == 'Running') { loggingOn = false; } - if (loggingOn) console.log(msg); + if (verbose || loggingOn) console.log(msg); }; page.onError = function (msg, trace) { diff --git a/test.sh b/test.sh index f54d6e0..9ca252e 100755 --- a/test.sh +++ b/test.sh @@ -16,4 +16,4 @@ if [ $? != 0 ]; then exit 1 fi -phantomjs phantom-driver.js +phantomjs phantom-driver.js $* -- 2.7.4