From 2ddad07fc761bc5aca85ff12eb0150b79edfdf63 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 09:51:02 -0400 Subject: [PATCH 1/8] Fix typo --- test/cli_test-samples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli_test-samples.js b/test/cli_test-samples.js index 2c958bdca2..4f7bfa691b 100644 --- a/test/cli_test-samples.js +++ b/test/cli_test-samples.js @@ -72,7 +72,7 @@ test.skip('sequence syntax error', function (t) { }); ['', 'fo', 'tspan', 'old'].forEach(function (textPlacement) { - test('sequence svg text placelment: ' + textPlacement, function (t) { + test('sequence svg text placement: ' + textPlacement, function (t) { t.plan(2) const args = ['--svg', '--outputDir=' + testDir, From e0f365662930598e2fac1974b7d9f0c4fd0661a7 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 09:52:06 -0400 Subject: [PATCH 2/8] Fix phantomjs invocation for Ubuntu 16.04 --- test/cli_test-samples.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/cli_test-samples.js b/test/cli_test-samples.js index 4f7bfa691b..1c35e8e7af 100644 --- a/test/cli_test-samples.js +++ b/test/cli_test-samples.js @@ -28,7 +28,12 @@ function execPhantomjsToLoadHtmlSaveScreenshotPng (html, verify) { function execCmd (cmd, verify) { console.log('cmd: ', cmd) exec(cmd, - { env: { PATH: './node_modules/.bin' + path.delimiter + process.env.PATH } }, + { env: { + PATH: './node_modules/.bin' + path.delimiter + process.env.PATH, + + // https://github.com/ariya/phantomjs/issues/14376 + QT_QPA_PLATFORM: 'offscreen' + } }, function (error, stdout, stderr) { console.log('error:', error, '\nstdout:\n', stdout, '\nstderr:\n', stderr) verify(error, stdout, stderr) From 4cfd18e25f30c225f3a57c3fbb8f0e0bcb55ec6d Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 09:57:30 -0400 Subject: [PATCH 3/8] Output all CLI log messages in the same way --- lib/phantomscript.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/phantomscript.js b/lib/phantomscript.js index 694167ed32..c2e445ff06 100644 --- a/lib/phantomscript.js +++ b/lib/phantomscript.js @@ -46,7 +46,7 @@ var options = { width: width, outputSuffix: system.args[9] } -var log = logger(options.verbose) +// var log = logger(options.verbose) options.sequenceConfig.useMaxWidth = false page.content = [ @@ -109,12 +109,13 @@ files.forEach(function (file) { , serialize.serializeToString(oDOM) + '\n' , 'w' ) - log('saved svg: ' + filename + '.svg') + console.log('saved svg: ' + filename + '.svg') } }) window.phantom.exit() +/* function logger (_verbose) { var verbose = _verbose @@ -130,6 +131,7 @@ function logger (_verbose) { } } } +*/ function resolveSVGElement (element) { var prefix = { From ef25bfee1445c80cce66f9542109bbc582aea6e0 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 10:04:50 -0400 Subject: [PATCH 4/8] Always use verbosity-aware CLI logging --- lib/phantomscript.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/phantomscript.js b/lib/phantomscript.js index c2e445ff06..43a21e8598 100644 --- a/lib/phantomscript.js +++ b/lib/phantomscript.js @@ -46,7 +46,7 @@ var options = { width: width, outputSuffix: system.args[9] } -// var log = logger(options.verbose) +var log = logger(options.verbose) options.sequenceConfig.useMaxWidth = false page.content = [ @@ -63,10 +63,10 @@ page.content = [ page.injectJs('../dist/mermaid.js') page.onConsoleMessage = function (msg, lineNum, sourceId) { - console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")') + log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")') } -console.log('Num files to execute : ' + files.length) +log('Num files to execute : ' + files.length) files.forEach(function (file) { var contents = fs.read(file) @@ -75,7 +75,7 @@ files.forEach(function (file) { var oDOM var svgContent - console.log('ready to execute png: ' + filename + '.png ') + log('ready to execute png: ' + filename + '.png ') // this JS is executed in this statement is sandboxed, even though it doesn't // look like it. we need to serialize then unserialize the svgContent that's @@ -100,7 +100,7 @@ files.forEach(function (file) { } page.render(outputPath + '.png') - console.log('saved png: ' + filename + '.png') + log('saved png: ' + filename + '.png') } if (options.svg) { @@ -109,13 +109,12 @@ files.forEach(function (file) { , serialize.serializeToString(oDOM) + '\n' , 'w' ) - console.log('saved svg: ' + filename + '.svg') + log('saved svg: ' + filename + '.svg') } }) window.phantom.exit() -/* function logger (_verbose) { var verbose = _verbose @@ -131,7 +130,6 @@ function logger (_verbose) { } } } -*/ function resolveSVGElement (element) { var prefix = { From de2db39161e0071b00dd33d6a82a1403da83bc84 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 10:14:11 -0400 Subject: [PATCH 5/8] Include file paths in CLI log output --- lib/phantomscript.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/phantomscript.js b/lib/phantomscript.js index 43a21e8598..2a24e150ac 100644 --- a/lib/phantomscript.js +++ b/lib/phantomscript.js @@ -75,7 +75,7 @@ files.forEach(function (file) { var oDOM var svgContent - log('ready to execute png: ' + filename + '.png ') + log('ready to execute: ' + file) // this JS is executed in this statement is sandboxed, even though it doesn't // look like it. we need to serialize then unserialize the svgContent that's @@ -100,7 +100,7 @@ files.forEach(function (file) { } page.render(outputPath + '.png') - log('saved png: ' + filename + '.png') + log('saved png: ' + outputPath + '.png') } if (options.svg) { @@ -109,7 +109,7 @@ files.forEach(function (file) { , serialize.serializeToString(oDOM) + '\n' , 'w' ) - log('saved svg: ' + filename + '.svg') + log('saved svg: ' + outputPath + '.svg') } }) From 981c3e0ce4e0e92b8a6d86b7bcc14dbc956f5e59 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 12:29:20 -0400 Subject: [PATCH 6/8] Inherit environment variables when testing --- test/cli_test-samples.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/cli_test-samples.js b/test/cli_test-samples.js index 1c35e8e7af..3fb9372ebf 100644 --- a/test/cli_test-samples.js +++ b/test/cli_test-samples.js @@ -4,6 +4,7 @@ const path = require('path') const test = require('tape') const rimraf = require('rimraf') +const localSearchPath = './node_modules/.bin' + path.delimiter + process.env.PATH const testDir = 'test/fixtures/samples/'.replace('/', path.sep) const phantomjs = 'node_modules/.bin/phantomjs '.replace('/', path.sep) const loadHtmlSaveScreenshotPngScripts = testDir + path.sep + 'load_html_save_screenshot_png.phantomjs' @@ -28,12 +29,7 @@ function execPhantomjsToLoadHtmlSaveScreenshotPng (html, verify) { function execCmd (cmd, verify) { console.log('cmd: ', cmd) exec(cmd, - { env: { - PATH: './node_modules/.bin' + path.delimiter + process.env.PATH, - - // https://github.com/ariya/phantomjs/issues/14376 - QT_QPA_PLATFORM: 'offscreen' - } }, + { env: Object.assign({}, process.env, { PATH: localSearchPath }) }, function (error, stdout, stderr) { console.log('error:', error, '\nstdout:\n', stdout, '\nstderr:\n', stderr) verify(error, stdout, stderr) From 905e0c20d901b67923dda0c0793e457561fa5409 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 12:40:22 -0400 Subject: [PATCH 7/8] Let Travis CI use headless chrome --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f098df05b5..dc710fa9c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ addons: - google-chrome packages: - google-chrome-stable + chrome: stable code_climate: repo_token: e87e6bf1c253e0555437ebd23235fdfe2749b889358e7c6d100e4ea5b4f2e091 language: node_js From e3585a7d6679d4fd1a3eb59ee7a21b175410a6f3 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 25 May 2017 12:53:28 -0400 Subject: [PATCH 8/8] Use valid values in .travis.yml --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc710fa9c6..f0493719df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,6 @@ sudo: required -dist: xenial +dist: trusty addons: - apt: - sources: - - google-chrome - packages: - - google-chrome-stable chrome: stable code_climate: repo_token: e87e6bf1c253e0555437ebd23235fdfe2749b889358e7c6d100e4ea5b4f2e091