Created
September 15, 2015 18:02
-
-
Save martintrojer/9a8e78126063705fabdb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var Ap = Array.prototype; | |
var slice = Ap.slice; | |
var Fp = Function.prototype; | |
if (!Fp.bind) { | |
// PhantomJS doesn't support Function.prototype.bind natively, so | |
// polyfill it whenever this module is required. | |
Fp.bind = function(context) { | |
var func = this; | |
var args = slice.call(arguments, 1); | |
function bound() { | |
var invokedAsConstructor = func.prototype && (this instanceof func); | |
return func.apply( | |
// Ignore the context parameter when invoking the bound function | |
// as a constructor. Note that this includes not only constructor | |
// invocations using the new keyword but also calls to base class | |
// constructors such as BaseClass.call(this, ...) or super(...). | |
!invokedAsConstructor && context || this, | |
args.concat(slice.call(arguments)) | |
); | |
} | |
// The bound function must share the .prototype of the unbound | |
// function so that any object created by one constructor will count | |
// as an instance of both constructors. | |
bound.prototype = func.prototype; | |
return bound; | |
}; | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> var apiUrl="http://api:8030"; </script> | |
<script> var sseUrl="http://see:8050"; </script> | |
<script src="phantomjs-shims.js" type="text/javascript"></script> | |
<script src="../target/site_tests.js" type="text/javascript"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global phantom,setTimeout,require,last_test_run_successful */ | |
var system = require('system'); | |
var page = require('webpage').create(); | |
var url = system.args[1]; | |
page.onConsoleMessage = function (message) { | |
console.log(message); | |
}; | |
function exit(code) { | |
setTimeout(function(){ phantom.exit(code); }, 0); | |
phantom.onError = function(){}; | |
} | |
console.log("Loading URL: " + url); | |
page.open(url, function (status) { | |
if (status != "success") { | |
console.log('Failed to open ' + url); | |
phantom.exit(1); | |
} | |
var result = page.evaluate(function() { | |
return azondi.site.core_test.run_all_phantom(); | |
}); | |
var last_test_run_successful = page.evaluate(function () { | |
return last_test_run_successful; | |
}); | |
if (last_test_run_successful) { | |
console.log("Tests succeeded."); | |
phantom.exit(0); | |
} else { | |
console.log("*** Tests failed! ***"); | |
phantom.exit(1); | |
} | |
}); |
Thanks! This solved it for me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What I think is happening:
The point being: the script never returns the control to the tests. Chrome, on the other hand, doesn't have an exiting mechanism, so it just returns the control to the tests without exiting.
My current solution is to set a function in ClojureScript that listens if the tests are done (we've implemented the reporting event
:end-run-tests
specifically for this purpose) which then calls another function called*exit-fn*
which can be set from the script, and does the final exit.There is a lot of indirection going on and I realize my answer might not be clear. Don't hesitate to ask questions.