mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
added testDemo to grunt test
This commit is contained in:
parent
a88b3badf5
commit
08c5648bb9
5 changed files with 33 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,4 +7,3 @@ build/matter-dev.js
|
||||||
build/matter-dev.min.js
|
build/matter-dev.min.js
|
||||||
demo/js/lib/matter-dev.js
|
demo/js/lib/matter-dev.js
|
||||||
tests/browser/diffs
|
tests/browser/diffs
|
||||||
tests/browser/worlds
|
|
|
@ -3,4 +3,5 @@ node_js:
|
||||||
- "0.10"
|
- "0.10"
|
||||||
before_install: npm install -g grunt-cli
|
before_install: npm install -g grunt-cli
|
||||||
install: npm install
|
install: npm install
|
||||||
before_script: grunt
|
before_script:
|
||||||
|
- grunt dev
|
23
Gruntfile.js
23
Gruntfile.js
|
@ -109,8 +109,11 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
shell: {
|
shell: {
|
||||||
testBrowser: {
|
testDemo: {
|
||||||
command: 'phantomjs tests/browser/TestDemo.js',
|
command: function(arg) {
|
||||||
|
arg = arg ? ' --' + arg : '';
|
||||||
|
return 'phantomjs tests/browser/TestDemo.js' + arg;
|
||||||
|
},
|
||||||
options: {
|
options: {
|
||||||
execOptions: {
|
execOptions: {
|
||||||
timeout: 1000 * 60
|
timeout: 1000 * 60
|
||||||
|
@ -131,10 +134,22 @@ module.exports = function(grunt) {
|
||||||
grunt.loadNpmTasks('grunt-shell');
|
grunt.loadNpmTasks('grunt-shell');
|
||||||
|
|
||||||
grunt.registerTask('default', ['test', 'build']);
|
grunt.registerTask('default', ['test', 'build']);
|
||||||
grunt.registerTask('test', ['jshint']);
|
grunt.registerTask('test', ['jshint', 'testDemo']);
|
||||||
grunt.registerTask('testBrowser', ['shell:testBrowser']);
|
|
||||||
grunt.registerTask('dev', ['build:dev', 'connect:watch', 'watch']);
|
grunt.registerTask('dev', ['build:dev', 'connect:watch', 'watch']);
|
||||||
|
|
||||||
|
grunt.registerTask('testDemo', function() {
|
||||||
|
var updateAll = grunt.option('updateAll'),
|
||||||
|
diff = grunt.option('diff');
|
||||||
|
|
||||||
|
if (updateAll) {
|
||||||
|
grunt.task.run('shell:testDemo:updateAll');
|
||||||
|
} else if (diff) {
|
||||||
|
grunt.task.run('shell:testDemo:diff');
|
||||||
|
} else {
|
||||||
|
grunt.task.run('shell:testDemo');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask('build', function(mode) {
|
grunt.registerTask('build', function(mode) {
|
||||||
var isDev = (mode === 'dev'),
|
var isDev = (mode === 'dev'),
|
||||||
isRelease = (mode === 'release'),
|
isRelease = (mode === 'release'),
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var Demo = {};
|
var Demo = {};
|
||||||
|
Matter.Demo = Demo;
|
||||||
|
|
||||||
var _engine,
|
var _engine,
|
||||||
_gui,
|
_gui,
|
||||||
|
@ -35,8 +36,6 @@
|
||||||
_useInspector = window.location.hash.indexOf('-inspect') !== -1,
|
_useInspector = window.location.hash.indexOf('-inspect') !== -1,
|
||||||
_isMobile = /(ipad|iphone|ipod|android)/gi.test(navigator.userAgent);
|
_isMobile = /(ipad|iphone|ipod|android)/gi.test(navigator.userAgent);
|
||||||
|
|
||||||
window.Matter.Demo = Demo;
|
|
||||||
|
|
||||||
// initialise the demo
|
// initialise the demo
|
||||||
|
|
||||||
Demo.init = function() {
|
Demo.init = function() {
|
||||||
|
@ -53,7 +52,6 @@
|
||||||
// create a Matter engine
|
// create a Matter engine
|
||||||
// NOTE: this is actually Matter.Engine.create(), see the aliases at top of this file
|
// NOTE: this is actually Matter.Engine.create(), see the aliases at top of this file
|
||||||
_engine = Engine.create(container, options);
|
_engine = Engine.create(container, options);
|
||||||
window.Matter.Demo._engine = _engine;
|
|
||||||
|
|
||||||
// add a mouse controlled constraint
|
// add a mouse controlled constraint
|
||||||
_mouseConstraint = MouseConstraint.create(_engine);
|
_mouseConstraint = MouseConstraint.create(_engine);
|
||||||
|
@ -1611,6 +1609,9 @@
|
||||||
var demoSelect = document.getElementById('demo-select'),
|
var demoSelect = document.getElementById('demo-select'),
|
||||||
demoReset = document.getElementById('demo-reset');
|
demoReset = document.getElementById('demo-reset');
|
||||||
|
|
||||||
|
// engine reference for external use
|
||||||
|
Matter.Demo._engine = _engine;
|
||||||
|
|
||||||
// create a Matter.Gui
|
// create a Matter.Gui
|
||||||
if (!_isMobile && Gui) {
|
if (!_isMobile && Gui) {
|
||||||
_gui = Gui.create(_engine);
|
_gui = Gui.create(_engine);
|
||||||
|
|
|
@ -53,6 +53,9 @@ var test = function(status) {
|
||||||
var worldStart = page.evaluate(function(demo) {
|
var worldStart = page.evaluate(function(demo) {
|
||||||
var engine = Matter.Demo._engine;
|
var engine = Matter.Demo._engine;
|
||||||
Matter.Runner.stop(engine);
|
Matter.Runner.stop(engine);
|
||||||
|
if (!(demo in Matter.Demo)) {
|
||||||
|
throw '\'' + demo + '\' is not defined in Matter.Demo';
|
||||||
|
}
|
||||||
Matter.Demo[demo]();
|
Matter.Demo[demo]();
|
||||||
return engine.world;
|
return engine.world;
|
||||||
}, demo);
|
}, demo);
|
||||||
|
@ -71,7 +74,7 @@ var test = function(status) {
|
||||||
|
|
||||||
if (fs.exists(worldStartPath)) {
|
if (fs.exists(worldStartPath)) {
|
||||||
var worldStartRef = resurrect.resurrect(fs.read(worldStartPath));
|
var worldStartRef = resurrect.resurrect(fs.read(worldStartPath));
|
||||||
var worldStartDiff = compare(worldStart, worldStartRef);
|
var worldStartDiff = compare(worldStartRef, worldStart);
|
||||||
|
|
||||||
if (worldStartDiff.length !== 0) {
|
if (worldStartDiff.length !== 0) {
|
||||||
if (diff) {
|
if (diff) {
|
||||||
|
@ -92,7 +95,7 @@ var test = function(status) {
|
||||||
|
|
||||||
if (fs.exists(worldEndPath)) {
|
if (fs.exists(worldEndPath)) {
|
||||||
var worldEndRef = resurrect.resurrect(fs.read(worldEndPath));
|
var worldEndRef = resurrect.resurrect(fs.read(worldEndPath));
|
||||||
var worldEndDiff = compare(worldEnd, worldEndRef);
|
var worldEndDiff = compare(worldEndRef, worldEnd);
|
||||||
|
|
||||||
if (worldEndDiff.length !== 0) {
|
if (worldEndDiff.length !== 0) {
|
||||||
if (diff) {
|
if (diff) {
|
||||||
|
@ -133,9 +136,9 @@ var test = function(status) {
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
console.log('ok');
|
console.log('ok');
|
||||||
} else {
|
} else {
|
||||||
console.log('changes detected on:');
|
console.log('\nchanges detected on:');
|
||||||
console.log(changed.join(', '));
|
console.log(changed.join(', '));
|
||||||
console.log('review, then --update [name] or --updateAll');
|
console.log('\nreview, then --update [name] or --updateAll');
|
||||||
console.log('use --diff for diff log');
|
console.log('use --diff for diff log');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue