mirror of
https://github.com/ariya/phantomjs.git
synced 2024-09-11 12:55:33 +03:00
Remove the old test runner.
Part of issue #13478 (test suite overhaul).
This commit is contained in:
parent
6106d391e9
commit
233b22ff2c
@ -18,7 +18,7 @@ before_script:
|
||||
|
||||
script:
|
||||
- ./build.sh --qtdeps=bundled --confirm --silent #< Build
|
||||
- ./test/run-tests.sh #< Test (PhantomJS)
|
||||
- ./test/run-tests.py #< Test (PhantomJS)
|
||||
- ./test/run-tests-ghostdriver.sh #< Test (GhostDriver / PhantomJSDriver)
|
||||
|
||||
notifications:
|
||||
|
@ -79,7 +79,7 @@ tests.push([function () {
|
||||
|
||||
tests.push([function () {
|
||||
assert_equals(require('./dummy'), 'require/dummy');
|
||||
assert_equals(require('../dummy'), 'spec/dummy');
|
||||
assert_equals(require('../fixtures/dummy'), 'spec/dummy');
|
||||
assert_equals(require('./dir/dummy'), 'dir/dummy');
|
||||
assert_equals(require('./dir/subdir/dummy'), 'subdir/dummy');
|
||||
assert_equals(require('./dir/../dummy'), 'require/dummy');
|
||||
@ -105,7 +105,7 @@ function require_paths_tests_1 () {
|
||||
'spec/node_modules/dummy_file2');
|
||||
assert_equals(require('../subdir2/loader'),
|
||||
'require/subdir2/loader');
|
||||
assert_equals(require('../dummy'), 'spec/dummy');
|
||||
assert_equals(require('../fixtures/dummy'), 'spec/dummy');
|
||||
}
|
||||
function require_paths_tests_2 () {
|
||||
assert_throws("Cannot find module 'loader'",
|
||||
|
0
test/dummy.js → test/fixtures/dummy.js
vendored
0
test/dummy.js → test/fixtures/dummy.js
vendored
@ -1,20 +0,0 @@
|
||||
Copyright (c) 2008-2011 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3403
test/lib/chai.js
3403
test/lib/chai.js
File diff suppressed because it is too large
Load Diff
@ -1,192 +0,0 @@
|
||||
jasmine.ConsoleReporter = function(print, doneCallback, showColors, verbose) {
|
||||
//inspired by mhevery's jasmine-node reporter
|
||||
//https://github.com/mhevery/jasmine-node
|
||||
|
||||
doneCallback = doneCallback || function() {};
|
||||
|
||||
var ansi = {
|
||||
green: '\033[32m',
|
||||
red: '\033[31m',
|
||||
yellow: '\033[33m',
|
||||
none: '\033[0m'
|
||||
},
|
||||
language = {
|
||||
spec: "spec",
|
||||
failure: "failure"
|
||||
};
|
||||
|
||||
function coloredStr(color, str) {
|
||||
return showColors ? (ansi[color] + str + ansi.none) : str;
|
||||
}
|
||||
|
||||
function greenStr(str) {
|
||||
return coloredStr("green", str);
|
||||
}
|
||||
|
||||
function redStr(str) {
|
||||
return coloredStr("red", str);
|
||||
}
|
||||
|
||||
function yellowStr(str) {
|
||||
return coloredStr("yellow", str);
|
||||
}
|
||||
|
||||
function newline() {
|
||||
print("\n");
|
||||
}
|
||||
|
||||
function started() {
|
||||
print("Started");
|
||||
newline();
|
||||
}
|
||||
|
||||
function greenDot() {
|
||||
print(greenStr("."));
|
||||
}
|
||||
|
||||
function redF() {
|
||||
print(redStr("F"));
|
||||
}
|
||||
|
||||
function yellowStar() {
|
||||
print(yellowStr("*"));
|
||||
}
|
||||
|
||||
function plural(str, count) {
|
||||
return count == 1 ? str : str + "s";
|
||||
}
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < times; i++) {
|
||||
arr.push(thing);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function indent(str, spaces) {
|
||||
var lines = (str || '').split("\n");
|
||||
var newArr = [];
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
newArr.push(repeat(" ", spaces).join("") + lines[i]);
|
||||
}
|
||||
return newArr.join("\n");
|
||||
}
|
||||
|
||||
function specFailureDetails(suiteDescription, specDescription, items) {
|
||||
newline();
|
||||
print(suiteDescription + " " + specDescription);
|
||||
newline();
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (!items[i].passed()) {
|
||||
if (items[i].trace.stack)
|
||||
print(indent(items[i].trace.stack, 2));
|
||||
else
|
||||
print(indent(items[i].toString(), 2));
|
||||
newline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function finished(elapsed) {
|
||||
newline();
|
||||
print("Finished in " + elapsed / 1000 + " seconds");
|
||||
}
|
||||
|
||||
function summary(colorF, specs, failed) {
|
||||
newline();
|
||||
print(colorF(specs + " " + plural(language.spec, specs) + ", " +
|
||||
failed + " " + plural(language.failure, failed)));
|
||||
newline();
|
||||
newline();
|
||||
}
|
||||
|
||||
function greenSummary(specs, failed) {
|
||||
summary(greenStr, specs, failed);
|
||||
}
|
||||
|
||||
function redSummary(specs, failed) {
|
||||
summary(redStr, specs, failed);
|
||||
}
|
||||
|
||||
function fullSuiteDescription(suite) {
|
||||
var fullDescription = suite.description;
|
||||
if (suite.parentSuite) fullDescription = fullSuiteDescription(suite.parentSuite) + " " + fullDescription;
|
||||
return fullDescription;
|
||||
}
|
||||
|
||||
this.now = function() {
|
||||
return new Date().getTime();
|
||||
};
|
||||
|
||||
this.reportRunnerStarting = function() {
|
||||
this.runnerStartTime = this.now();
|
||||
started();
|
||||
};
|
||||
|
||||
this.reportSpecStarting = function() { /* do nothing */
|
||||
};
|
||||
|
||||
this.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
if (verbose) {
|
||||
var msg;
|
||||
if (results.skipped) {
|
||||
msg = yellowStr("SKIP");
|
||||
} else if (results.passed()) {
|
||||
msg = greenStr("PASS");
|
||||
} else {
|
||||
msg = redStr("FAIL");
|
||||
}
|
||||
msg += " " + spec.getFullName();
|
||||
print(msg);
|
||||
newline();
|
||||
} else {
|
||||
if (results.skipped) {
|
||||
yellowStar();
|
||||
} else if (results.passed()) {
|
||||
greenDot();
|
||||
} else {
|
||||
redF();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.suiteResults = [];
|
||||
|
||||
this.reportSuiteResults = function(suite) {
|
||||
var suiteResult = {
|
||||
description: fullSuiteDescription(suite),
|
||||
failedSpecResults: []
|
||||
};
|
||||
|
||||
suite.results().items_.forEach(function(spec) {
|
||||
if (spec.failedCount > 0 && spec.description) suiteResult.failedSpecResults.push(spec);
|
||||
});
|
||||
|
||||
this.suiteResults.push(suiteResult);
|
||||
};
|
||||
|
||||
function eachSpecFailure(suiteResults, callback) {
|
||||
for (var i = 0; i < suiteResults.length; i++) {
|
||||
var suiteResult = suiteResults[i];
|
||||
for (var j = 0; j < suiteResult.failedSpecResults.length; j++) {
|
||||
var failedSpecResult = suiteResult.failedSpecResults[j];
|
||||
callback(suiteResult.description, failedSpecResult.description,
|
||||
failedSpecResult.items_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.reportRunnerResults = function(runner) {
|
||||
newline();
|
||||
eachSpecFailure(this.suiteResults, specFailureDetails);
|
||||
|
||||
finished(this.now() - this.runnerStartTime);
|
||||
|
||||
var results = runner.results();
|
||||
var summaryFunction = results.failedCount === 0 ? greenSummary : redSummary;
|
||||
summaryFunction(runner.specs().length, results.failedCount);
|
||||
doneCallback(runner);
|
||||
};
|
||||
};
|
2600
test/lib/jasmine.js
2600
test/lib/jasmine.js
File diff suppressed because it is too large
Load Diff
@ -119,7 +119,8 @@ async_test(function () {
|
||||
var page = require("webpage").create();
|
||||
var url = "http://localhost:"+port+"/";
|
||||
var fs = require("fs");
|
||||
var png = fs.read(fs.join(phantom.libraryPath, "../../phantomjs.png"), "b");
|
||||
var png = fs.read(fs.join(phantom.libraryPath,
|
||||
"../../www/phantomjs.png"), "b");
|
||||
|
||||
arm_check_request(this, false, png, "image/png");
|
||||
page.open(url, "get", this.step_func_done(function (status) {
|
||||
|
@ -1,110 +0,0 @@
|
||||
//! no-harness
|
||||
|
||||
/*
|
||||
This file is part of the PhantomJS project from Ofi Labs.
|
||||
|
||||
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
Copyright (C) 2011 Ivan De Marino <ivan.de.marino@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Set the working directory to the "/test" directory if it's not
|
||||
// already there.
|
||||
var fs = require('fs');
|
||||
fs.changeWorkingDirectory(phantom.libraryPath);
|
||||
|
||||
// Load Jasmine and the HTML reporter
|
||||
phantom.injectJs("./lib/jasmine.js");
|
||||
phantom.injectJs("./lib/jasmine-console.js");
|
||||
phantom.injectJs("./lib/chai.js");
|
||||
|
||||
var should = chai.should();
|
||||
|
||||
// Helper funcs
|
||||
function expectHasFunction(o, name) {
|
||||
it("should have '" + name + "' function", function() {
|
||||
expect(typeof o[name]).toEqual('function');
|
||||
});
|
||||
}
|
||||
|
||||
function expectHasProperty(o, name) {
|
||||
it("should have '" + name + "' property", function() {
|
||||
expect(o.hasOwnProperty(name)).toBeTruthy();
|
||||
});
|
||||
}
|
||||
|
||||
function expectHasPropertyString(o, name) {
|
||||
expectHasProperty(o, name);
|
||||
|
||||
it("should have '" + name + "' as a string", function() {
|
||||
expect(typeof o[name]).toEqual('string');
|
||||
});
|
||||
}
|
||||
|
||||
// Load specs
|
||||
phantom.injectJs("./webpage-spec.js");
|
||||
|
||||
// Environment configuration
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
|
||||
// Command line arguments
|
||||
var sys = require("system");
|
||||
var verbose = false;
|
||||
if (sys.args.length > 1) {
|
||||
var rest = 1;
|
||||
if (sys.args[1] == "-v" || sys.args[1] == "--verbose") {
|
||||
verbose = true;
|
||||
rest = 2;
|
||||
} else if (sys.args[1].slice(0, "--verbose=".length) == "--verbose=") {
|
||||
verbose = parseInt(sys.args[1].slice("--verbose=".length)) > 0;
|
||||
rest = 2;
|
||||
}
|
||||
|
||||
if (sys.args.length > rest) {
|
||||
var specFilterRe = new RegExp(sys.args.slice(rest).join(" "));
|
||||
jasmineEnv.specFilter = function (spec) {
|
||||
return specFilterRe.test(spec.getFullName());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Add a ConsoleReporter to 1) print with colors on the console
|
||||
// 2) exit when finished
|
||||
jasmineEnv.addReporter(new jasmine.ConsoleReporter(
|
||||
// Print messages straight to the console, and don't mess with the newlines
|
||||
sys.stdout.write.bind(sys.stdout),
|
||||
// On complete, exit unsuccessfully if any tests failed
|
||||
function (reporter) {
|
||||
phantom.exit(reporter.results().failedCount > 0 ? 1 : 0);
|
||||
},
|
||||
// Colorized (but disable colorized output on Windows by default)
|
||||
sys.os.name == 'windows' ? false : true,
|
||||
// Verbosity
|
||||
verbose
|
||||
));
|
||||
|
||||
// Launch tests
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
jasmineEnv.execute();
|
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
exec "${0%/*}/../bin/phantomjs" "${0%/*}/run-tests.js" "$@"
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Loading…
Reference in New Issue
Block a user