Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow harmony flag to executed server #86

Merged
merged 1 commit into from
Apr 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ module.exports = function(grunt) {
custom_cmd: {
src: 'test/custom_cmd_test.js'
},
custom_harmony: {
src: 'test/custom_harmony.js'
},
custom_args: {
src: 'test/custom_args_test.js'
},
Expand Down Expand Up @@ -90,6 +93,12 @@ module.exports = function(grunt) {
script: './test/server_malformed.js'
}
},
custom_harmony: {
options: {
harmony: true,
output: "Express server listening on port .+"
}
},
custom_args: {
options: {
args: [1, 2],
Expand Down Expand Up @@ -153,37 +162,40 @@ module.exports = function(grunt) {
grunt.registerTask('test', [
'clean',
'nodeunit:defaults',
'express:defaults',
'express:defaults',
'express:defaults:stop',
'express:malformed',
'express:custom_cmd',
'nodeunit:custom_cmd',
'express:custom_cmd',
'nodeunit:custom_cmd',
'express:custom_cmd:stop',
'express:custom_args',
'nodeunit:custom_args',
'express:custom_args',
'nodeunit:custom_args',
'express:custom_args:stop',
'express:custom_port',
'nodeunit:custom_port',
'express:custom_harmony',
'nodeunit:custom_harmony',
'express:custom_harmony:stop',
'express:custom_port',
'nodeunit:custom_port',
'express:custom_port:stop',
'express:custom_node_env',
'nodeunit:custom_node_env',
'express:custom_node_env',
'nodeunit:custom_node_env',
'express:custom_node_env:stop',
'express:custom_delay',
'nodeunit:custom_delay',
'express:custom_delay',
'nodeunit:custom_delay',
'express:custom_delay:stop',
'express:custom_output',
'nodeunit:custom_output',
'express:custom_output',
'nodeunit:custom_output',
'express:custom_output:stop',
'express:stoppable',
'express:stoppable:stop',
'express:stoppable',
'express:stoppable:stop',
'nodeunit:stoppable',

// Multiple servers
'express:custom_port',
'nodeunit:defaults',
'express:defaults',
'express:custom_port',
'nodeunit:defaults',
'express:defaults',
'nodeunit:custom_port',
'express:custom_port:stop',
'express:custom_port:stop',
'express:defaults:stop',
]);

Expand Down
5 changes: 5 additions & 0 deletions tasks/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = function(grunt) {
opts: [ ],
args: [ ],
node_env: undefined,
harmony: false,
background: true,
fallback: function() { /* Prevent EADDRINUSE from breaking Grunt */ },
port: process.env.PORT || 3000,
Expand All @@ -40,6 +41,10 @@ module.exports = function(grunt) {

options.args.unshift(options.script);

if (options.harmony) {
options.args.unshift('--harmony');
}

if (!grunt.file.exists(options.script)) {
grunt.log.error('Could not find server script: ' + options.script);

Expand Down
4 changes: 4 additions & 0 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ app.get('/env', function(req, res) {
res.send('Howdy from ' + app.get('env') + '!');
});

app.get('/harmony', function(req, res) {
res.send('Harmony flag idx is ' + process.execArgv.indexOf('--harmony'));
});

// Setup simple echo for each additional argument passed for testing
args.slice(2).forEach(function(arg) {
app.get('/' + arg, function(req, res) {
Expand Down
24 changes: 24 additions & 0 deletions test/custom_harmony.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* grunt-express-server
* https://github.com/ericclemmons/grunt-express-server
*
* Copyright (c) 2013 Eric Clemmons
* Licensed under the MIT license.
*/

'use strict';

var get = require('./lib/get');

module.exports.custom_args = {
test_runs_in_harmony: function(test) {
test.expect(2);
get('http://localhost:3000/harmony', function(res, body) {
test.equal(res.statusCode, 200, 'should return 200');
test.equal(body, 'Harmony flag idx is 0');
test.done();
}, function(err) {
test.done();
});
}
};
1 change: 0 additions & 1 deletion test/custom_node_env_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var get = require('./lib/get');
module.exports.custom_node_env = {
test_site_configured_for_production: function(test) {
test.expect(2);

get('http://localhost:3000/env', function(res, body) {
test.equal(res.statusCode, 200, 'should return 200');
test.equal(body, 'Howdy from production!', 'should return dynamic page');
Expand Down