Skip to content

Commit f0f748d

Browse files
author
ionut.stan
committed
Added better handling for some phantomjs test missing dependencies.
1 parent d0ff964 commit f0f748d

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jsonrpc-bidirectional",
33
"description": "Bidirectional JSONRPC over web sockets or HTTP with extensive plugin support.",
4-
"version": "3.2.2",
4+
"version": "3.2.3",
55
"scripts": {
66
"build": "node build.js",
77
"test": "node --expose-gc --max-old-space-size=3072 tests/main.js",

tests/AllTests.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
const JSONRPC = require("..");
22

3+
const exec = require("child_process").exec;
4+
35
const http = require("http");
46
const url = require("url");
57
const path = require("path");
68
const fs = require("fs");
9+
const os = require("os");
710

811
const sleep = require("sleep-promise");
912

@@ -1011,16 +1014,40 @@ class AllTests
10111014
}
10121015
);
10131016

1017+
let phantomPage;
10141018
try
10151019
{
1016-
const phantomPage = await phantom.createPage();
1020+
phantomPage = await phantom.createPage();
10171021
}
10181022
catch(error)
10191023
{
1020-
if(error.message.includes("Error reading from stdin"))
1024+
if(
1025+
error.message.includes("Error reading from stdin")
1026+
&& os.platform() === "linux"
1027+
)
10211028
{
10221029
// https://github.com/amir20/phantomjs-node/issues/649
1023-
return;
1030+
console.error("phantomjs may have reported an error in the phantom library.");
1031+
console.error("If missing phantomjs dependencies: yum install libXext libXrender fontconfig libfontconfig.so.1");
1032+
1033+
const processCommand = exec("../node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs --help");
1034+
processCommand.stdout.pipe(process.stdout);
1035+
processCommand.stderr.pipe(process.stderr);
1036+
await new Promise(async (fnResolve, fnReject) => {
1037+
processCommand.on("error", fnReject);
1038+
processCommand.on("exit", (nCode) => {
1039+
if(nCode === 0)
1040+
{
1041+
fnResolve();
1042+
}
1043+
else
1044+
{
1045+
fnReject(new Error("Failed with error code " + nCode));
1046+
}
1047+
});
1048+
});
1049+
1050+
process.exit(1);
10241051
}
10251052

10261053
throw error;

0 commit comments

Comments
 (0)