Skip to content

Commit

Permalink
Merge branch 'saucelabs-test-fix' into saucelabs-tests
Browse files Browse the repository at this point in the history
Conflicts:
	Gruntfile.js
	package.json
	tests/mithril-tests.js
	tests/test.js
  • Loading branch information
mambocab committed Jul 28, 2014
2 parents 4d41c08 + 3160e69 commit 21d6351
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 40 deletions.
8 changes: 4 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_ = require('lodash')
module.exports = function(grunt) {
_ = require('lodash');

var version = "0.1.19"

Expand Down Expand Up @@ -70,7 +70,7 @@ module.exports = function(grunt) {
];

var sauceOnTestComplete = function(result, callback) {
var request = require('request')
var request = require('request');

var user = process.env.SAUCE_USERNAME;
var pass = process.env.SAUCE_ACCESS_KEY;
Expand Down Expand Up @@ -198,7 +198,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-saucelabs')
grunt.loadNpmTasks('grunt-saucelabs');

grunt.registerTask("build", ["test", "uglify", "zip", "md2html", "replace", "copy", "clean"]);
grunt.registerTask("test", ["concat", "execute"]);
Expand All @@ -207,5 +207,5 @@ module.exports = function(grunt) {

grunt.registerTask("sauce-qunit", ["connect", "saucelabs-qunit"]);
grunt.registerTask("sauce-custom", ["connect", "saucelabs-custom"]);
grunt.registerTask("sauce-all", ["connect", "saucelabs-qunit", "saucelabs-custom"])
grunt.registerTask("sauce-all", ["connect", "saucelabs-qunit", "saucelabs-custom"]);
};
50 changes: 45 additions & 5 deletions archive/v0.1.19/mithril-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,39 @@ if (typeof define == "function" && define.amd) define(function() {return m})
;;;

function test(condition) {
try {if (!condition()) throw new Error}
catch (e) {console.error(e);test.failures.push(condition)}
var duration = 0;
var start = 0;
var result = true;
test.total++

if (typeof window != "undefined") {
if (typeof performance != "undefined") {
start = performance.now();
}
try {if (!condition()) throw new Error}
catch (e) {result = false;console.error(e);test.failures.push(condition)}
if (typeof performance != "undefined") {
duration = performance.now() - start;
}


test_obj = {
name: "" + test.total,
result: result,
duration: duration
}
if (!result) {
message: "failed: " + condition,
window.global_test_results.tests.push(test_obj)
}

window.global_test_results.duration += duration;
if (result) {
window.global_test_results.passed++;
} else {
window.global_test_results.failed++;
}
}
}
test.total = 0
test.failures = []
Expand Down Expand Up @@ -2381,7 +2411,17 @@ function testMithril(mock) {

}

//mocks
testMithril(mock.window)
//test reporting for saucelabs
if (typeof window != "undefined") {
window.global_test_results = {
tests: [],
duration: 0,
passed: 0,
failed: 0
};
}

//mock
testMithril(mock.window);

test.print(console.log)
test.print(function(value){console.log(value)});
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@
"grunt-contrib-qunit": "*",
"grunt-contrib-connect": "*",
"grunt-zip": "*",

"grunt-contrib-connect": "~0.7.1",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-jscs-checker": "^0.4.4",
"grunt-sauce-tunnel": "^0.2.1",
"load-grunt-config": "^0.9.2",
"merge": "^1.1.3",
"publish": "~0.3.2",
"grunt-saucelabs": "*",
"request": "~2.35.0",
"q": "~1.0.0",
"saucelabs": "~0.1.1",
"sauce-tunnel": "~2.0.6",
"colors": "~0.6.2",
"lodash": "~2.4.1"
},
}
}
14 changes: 8 additions & 6 deletions tests/mithril-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1576,12 +1576,14 @@ function testMithril(mock) {
}

//test reporting for saucelabs
window.global_test_results = {
tests: [],
duration: 0,
passed: 0,
failed: 0
};
if (typeof window != "undefined") {
window.global_test_results = {
tests: [],
duration: 0,
passed: 0,
failed: 0
};
}

//mock
testMithril(mock.window);
Expand Down
51 changes: 27 additions & 24 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
function test(condition) {
var duration = 0;
var start = 0;
var result = true
if (performance.now) {
start = performance.now();
}
try {if (!condition()) throw new Error}
catch (e) {result = false;console.error(e);test.failures.push(condition)}
if (performance.now) {
duration = performance.now() - start;
}

var result = true;
test.total++

test_obj = {
name: "" + test.total,
result: result,
duration: duration
}
if (!result) {
message: "failed: " + condition,
window.global_test_results.tests.push(test_obj)
}
if (typeof window != "undefined") {
if (typeof performance != "undefined") {
start = performance.now();
}
try {if (!condition()) throw new Error}
catch (e) {result = false;console.error(e);test.failures.push(condition)}
if (typeof performance != "undefined") {
duration = performance.now() - start;
}


test_obj = {
name: "" + test.total,
result: result,
duration: duration
}
if (!result) {
message: "failed: " + condition,
window.global_test_results.tests.push(test_obj)
}

window.global_test_results.duration += duration;
if (result) {
window.global_test_results.passed++;
} else {
window.global_test_results.failed++;
window.global_test_results.duration += duration;
if (result) {
window.global_test_results.passed++;
} else {
window.global_test_results.failed++;
}
}
}
test.total = 0
Expand Down

0 comments on commit 21d6351

Please sign in to comment.