From 0b77d7f7989230727afd85a9f9bb3c3a99d87b5c Mon Sep 17 00:00:00 2001 From: Reid Burke Date: Fri, 28 Feb 2014 16:48:07 -0800 Subject: [PATCH 1/7] Add test for #78, bad output for moduleless QUnit. --- package.json | 2 +- test/functional/junit.js | 132 +++++++++++++++++++++++++++++++++++++++ test/lib/cli.js | 35 +++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 test/functional/junit.js create mode 100644 test/lib/cli.js diff --git a/package.json b/package.json index 3c22604a..60f0de72 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,6 @@ "jake": ">=0.2.35", "rimraf": ">=2.0.1", "walkdir": ">=0.0.5", - "mock-utf8-stream": ">=0.1.0" + "mock-utf8-stream": ">=0.1.1" } } diff --git a/test/functional/junit.js b/test/functional/junit.js new file mode 100644 index 00000000..0ceebdf5 --- /dev/null +++ b/test/functional/junit.js @@ -0,0 +1,132 @@ +"use strict"; + +var vows = require("vows"); +var assert = require("assert"); + +var portfinder = require("portfinder"); + +var hub = require("../lib/hub"); +var cliTopic = require("../lib/cli"); + +var EventEmitter2 = require("../../lib/event-emitter"); + +vows.describe("Yeti JUnit Functional").addBatch({ + "A Yeti CLI with moduleless QUnit with JUnit output": { + topic: cliTopic(function (topic) { + var vow = this; + + topic.stderr.startCapture(); + + portfinder.getPort(function (err, port) { + if (err) { + vow.callback(err); + return; + } + + port = String(port); + topic.port = port; + + topic.stderr.expect("When ready", function () { + topic.stderr.stopCapture(); + topic.output = topic.stderr.capturedData; + vow.callback(null, topic); + }); + + topic.fe.route([ + "node", + "cli.js", + "--junit", + "-p", port, + __dirname + "/fixture/qunit.html" + ]); + }); + }), + "is ok": function (topic) { + assert.isUndefined(topic.stack); + }, + "prints hub creation message on stderr": function (topic) { + assert.ok(topic.output.indexOf("Creating a Hub.") === 0); + }, + "waits for agents to connect on stderr": function (topic) { + assert.include(topic.output, "Waiting for agents to connect"); + }, + "prompts on the writableStream": function (topic) { + assert.include(topic.output, "When ready, press Enter"); + }, + "a browser": hub.phantomContext({ + "visits Yeti": { + topic: function (browser, topic) { + var vow = this; + + topic.browser = browser; + + topic.stderr.expect("Agent connected", function (err, capturedData) { + topic.output = capturedData; + vow.callback(null, topic); + }); + + function onPageOpen(err, status) { + if (err) { + vow.callback(err); + } + } + + browser.createPage(function (err, page) { + page.open("http://localhost:" + topic.port, onPageOpen); + }); + }, + "is ok": function (topic) { + assert.isUndefined(topic.stack); + }, + "the stderr output contains the User-Agent": function (topic) { + assert.include(topic.output, "PhantomJS"); + }, + "when Enter is pressed": { + topic: function (topic) { + var vow = this; + + topic.stderr.expect("pass", function (err, capturedData) { + topic.output = capturedData; + vow.callback(null, topic); + }); + + topic.stdout.startCapture(); + + topic.stdin.write("\n"); // Enter + }, + "is ok": function (topic) { + assert.isUndefined(topic.stack); + }, + "the stderr output contains the test summary": function (topic) { + // FIXME, tests should be test + assert.include(topic.output, "1 tests passed"); + }, + "the stderr output contains Agent complete": function (topic) { + assert.include(topic.output, "Agent complete"); + }, + "should exit": { + topic: function (topic) { + var vow = this; + topic.emitter.once("exit", function (code) { + topic.stdout.stopCapture(); + topic.exitCode = code; + vow.callback(null, topic); + }); + }, + "with status code 0": function (topic) { + assert.strictEqual(topic.exitCode, 0); + }, + "the stdout output contains JUnit XML": function (topic) { + assert.ok(topic.stdout.capturedData.indexOf(""); + }, + "the stdout output contains a JUnit testcase": function (topic) { + // https://github.com/yui/yeti/issues/78 + assert.include(topic.stdout.capturedData, ' Date: Fri, 28 Feb 2014 16:37:24 -0800 Subject: [PATCH 2/7] Do not autostart QUnit. --- test/functional/fixture/qunit.html | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/fixture/qunit.html b/test/functional/fixture/qunit.html index 14342209..c0be71c2 100644 --- a/test/functional/fixture/qunit.html +++ b/test/functional/fixture/qunit.html @@ -6,6 +6,7 @@
+ From 008bc26832f5e2e9f8a89f48ffe3bbf6e1eb6adf Mon Sep 17 00:00:00 2001 From: Reid Burke Date: Mon, 3 Mar 2014 15:38:45 -0800 Subject: [PATCH 5/7] Add assertion failure message for XML prolog test. --- test/functional/junit.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/junit.js b/test/functional/junit.js index 0ceebdf5..f1ed788d 100644 --- a/test/functional/junit.js +++ b/test/functional/junit.js @@ -117,7 +117,8 @@ vows.describe("Yeti JUnit Functional").addBatch({ assert.strictEqual(topic.exitCode, 0); }, "the stdout output contains JUnit XML": function (topic) { - assert.ok(topic.stdout.capturedData.indexOf(""); }, "the stdout output contains a JUnit testcase": function (topic) { From a97191adcc19fc6e3b46cbc7e0c7fdc7a2583c62 Mon Sep 17 00:00:00 2001 From: Reid Burke Date: Mon, 3 Mar 2014 16:50:06 -0800 Subject: [PATCH 6/7] Start capturing stdout earlier in the test. Attempts to correct test race condition seen in https://travis-ci.org/yui/yeti/jobs/20017403 --- test/functional/junit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/junit.js b/test/functional/junit.js index f1ed788d..264a4a1d 100644 --- a/test/functional/junit.js +++ b/test/functional/junit.js @@ -32,6 +32,8 @@ vows.describe("Yeti JUnit Functional").addBatch({ vow.callback(null, topic); }); + topic.stdout.startCapture(); + topic.fe.route([ "node", "cli.js", @@ -90,8 +92,6 @@ vows.describe("Yeti JUnit Functional").addBatch({ vow.callback(null, topic); }); - topic.stdout.startCapture(); - topic.stdin.write("\n"); // Enter }, "is ok": function (topic) { From 9b274ba26513513090232f56ab7848e45817b00d Mon Sep 17 00:00:00 2001 From: Reid Burke Date: Tue, 4 Mar 2014 16:18:39 -0800 Subject: [PATCH 7/7] Add --isolate to Vows command. Attempt to fix XML prolog test failure in Travis by running that functional test file by itself. Note that this only affects files, not individual tests. --- Jakefile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 19073ef3..49e4ed6a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -87,7 +87,7 @@ task("install", function () { desc("Run all of Yeti's functional tests"); task("test-functional", function () { - var args = ["--spec"]; + var args = ["--isolate", "--spec"]; bin("vows", args.concat(getTestFiles("functional")), complete); }, { async: true @@ -95,7 +95,7 @@ task("test-functional", function () { desc("Run all of Yeti's unit tests"); task("test-unit", function () { - var args = []; + var args = ["--isolate"]; if (process.env.TRAVIS) { args.push("--spec"); }