|
@ -118,26 +118,37 @@ function handleCompilerCallback(err, stats) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function startDevWebserver(cb) { |
|
|
|
|
|
return gulp.src('./').pipe(webserver({ |
|
|
|
|
|
|
|
|
function startDevWebserver(options, cb) { |
|
|
|
|
|
var opt = options || {}; |
|
|
|
|
|
return gulp.src('./').pipe(webserver(Object.assign(opt, { |
|
|
path: '/', |
|
|
path: '/', |
|
|
port: geminiConfig.webserver.port |
|
|
port: geminiConfig.webserver.port |
|
|
})); |
|
|
|
|
|
|
|
|
}))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
gulp.task('gemini-webserver', function(cb) { |
|
|
|
|
|
startDevWebserver(cb); |
|
|
|
|
|
|
|
|
// Starts a static webserver that serve files from the root-dir of the project
|
|
|
|
|
|
// during development. This is also used for gemini-testing.
|
|
|
|
|
|
gulp.task('webserver', function(cb) { |
|
|
|
|
|
startDevWebserver({ |
|
|
|
|
|
livereload: true, |
|
|
|
|
|
directoryListing: true, |
|
|
|
|
|
open: true |
|
|
|
|
|
}, cb); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function runGemini(mode, cb) { |
|
|
function runGemini(mode, cb) { |
|
|
|
|
|
var completed = false; |
|
|
|
|
|
var hasError = false; |
|
|
|
|
|
|
|
|
|
|
|
// start development webserver to server the test-files
|
|
|
var server = startDevWebserver(); |
|
|
var server = startDevWebserver(); |
|
|
|
|
|
|
|
|
|
|
|
// start phantomjs in webdriver mode
|
|
|
var phantomjsProcess = spawn('phantomjs', [ |
|
|
var phantomjsProcess = spawn('phantomjs', [ |
|
|
'--webdriver=' + geminiConfig.phantomjs.port |
|
|
'--webdriver=' + geminiConfig.phantomjs.port |
|
|
]); |
|
|
]); |
|
|
var completed = false; |
|
|
|
|
|
var hasError = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read output from the phantomjs process
|
|
|
phantomjsProcess.stdout.on('data', function(data) { |
|
|
phantomjsProcess.stdout.on('data', function(data) { |
|
|
if (data.toString().indexOf('running on port') >= 0) { |
|
|
if (data.toString().indexOf('running on port') >= 0) { |
|
|
gutil.log("Started phantomjs webdriver"); |
|
|
gutil.log("Started phantomjs webdriver"); |
|
@ -165,35 +176,46 @@ function runGemini(mode, cb) { |
|
|
geminiProcess.on('close', function(code) { |
|
|
geminiProcess.on('close', function(code) { |
|
|
completed = true; |
|
|
completed = true; |
|
|
phantomjsProcess.kill(); |
|
|
phantomjsProcess.kill(); |
|
|
server.emit('kill'); |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Log all error output from the phantomjs process to the console
|
|
|
phantomjsProcess.stderr.on('data', function(data) { |
|
|
phantomjsProcess.stderr.on('data', function(data) { |
|
|
gutil.log(gutil.colors.red(data)); |
|
|
gutil.log(gutil.colors.red(data)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Cleanup after phantomjs closes
|
|
|
phantomjsProcess.on('close', function(code) { |
|
|
phantomjsProcess.on('close', function(code) { |
|
|
|
|
|
gutil.log("Phantomjs webdriver stopped"); |
|
|
|
|
|
|
|
|
if (code && !completed) { |
|
|
if (code && !completed) { |
|
|
|
|
|
// phantomjs closed with an error
|
|
|
|
|
|
server.emit('kill'); |
|
|
return cb(new Error('✘ phantomjs failed with code: ' + code + '\n' + |
|
|
return cb(new Error('✘ phantomjs failed with code: ' + code + '\n' + |
|
|
'Check that port ' + geminiConfig.phantomjs.port + |
|
|
'Check that port ' + geminiConfig.phantomjs.port + |
|
|
' is free and that there are no other ' + |
|
|
' is free and that there are no other ' + |
|
|
'instances of phantomjs running. (`killall phantomjs`)')); |
|
|
'instances of phantomjs running. (`killall phantomjs`)')); |
|
|
} |
|
|
} |
|
|
gutil.log("Stoped phantomjs webdriver"); |
|
|
|
|
|
|
|
|
|
|
|
if (hasError) { |
|
|
if (hasError) { |
|
|
gutil.log("Opening report in webbrowser"); |
|
|
|
|
|
opn(geminiConfig.gemini.reports); |
|
|
|
|
|
|
|
|
// The tests returned with an error. Show the report. Keep dev-webserver running for debugging.
|
|
|
|
|
|
gutil.log(gutil.colors.red("Opening error-report in webbrowser")); |
|
|
|
|
|
opn(geminiConfig.gemini.reports + 'index.html'); |
|
|
|
|
|
} else { |
|
|
|
|
|
// The tests returned no error. Kill the dev-webserver and exit
|
|
|
|
|
|
server.emit('kill'); |
|
|
|
|
|
cb(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
cb(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Update the screenshots. Do this everytime you introduced a new test or introduced a major change.
|
|
|
gulp.task('gemini-update', function(cb) { |
|
|
gulp.task('gemini-update', function(cb) { |
|
|
runGemini('update', cb); |
|
|
runGemini('update', cb); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Test the current (dist) version against the existing screenshots.
|
|
|
gulp.task('gemini-test', function(cb) { |
|
|
gulp.task('gemini-test', function(cb) { |
|
|
runGemini('test', cb); |
|
|
runGemini('test', cb); |
|
|
}); |
|
|
}); |
|
|