2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2011-01-25 02:52:38 +01:00
|
|
|
(function() {
|
|
|
|
var assert = require('assert'),
|
2011-10-05 00:08:18 +02:00
|
|
|
child = require('child_process'),
|
|
|
|
util = require('util'),
|
2011-01-25 02:52:38 +01:00
|
|
|
common = require('../common');
|
|
|
|
if (process.env['TEST_INIT']) {
|
|
|
|
util.print('Loaded successfully!');
|
|
|
|
} else {
|
|
|
|
// change CWD as we do this test so its not dependant on current CWD
|
|
|
|
// being in the test folder
|
|
|
|
process.chdir(__dirname);
|
|
|
|
|
2013-04-16 09:51:56 +02:00
|
|
|
// slow but simple
|
|
|
|
var envCopy = JSON.parse(JSON.stringify(process.env));
|
|
|
|
envCopy.TEST_INIT = 1;
|
|
|
|
|
2015-03-12 02:16:26 +01:00
|
|
|
child.exec('"' + process.execPath + '" test-init', {env: envCopy},
|
2011-10-05 00:08:18 +02:00
|
|
|
function(err, stdout, stderr) {
|
2012-01-17 19:43:34 +01:00
|
|
|
assert.equal(stdout, 'Loaded successfully!',
|
|
|
|
'`node test-init` failed!');
|
2011-10-05 00:08:18 +02:00
|
|
|
});
|
2015-03-12 02:16:26 +01:00
|
|
|
child.exec('"' + process.execPath + '" test-init.js', {env: envCopy},
|
2011-10-05 00:08:18 +02:00
|
|
|
function(err, stdout, stderr) {
|
2012-01-17 19:43:34 +01:00
|
|
|
assert.equal(stdout, 'Loaded successfully!',
|
|
|
|
'`node test-init.js` failed!');
|
2011-10-05 00:08:18 +02:00
|
|
|
});
|
2011-01-25 02:52:38 +01:00
|
|
|
|
|
|
|
// test-init-index is in fixtures dir as requested by ry, so go there
|
|
|
|
process.chdir(common.fixturesDir);
|
|
|
|
|
2015-03-12 02:16:26 +01:00
|
|
|
child.exec('"' + process.execPath + '" test-init-index', {env: envCopy},
|
2011-10-05 00:08:18 +02:00
|
|
|
function(err, stdout, stderr) {
|
2012-01-17 19:43:34 +01:00
|
|
|
assert.equal(stdout, 'Loaded successfully!',
|
|
|
|
'`node test-init-index failed!');
|
2011-10-05 00:08:18 +02:00
|
|
|
});
|
2011-01-25 02:52:38 +01:00
|
|
|
|
|
|
|
// ensures that `node fs` does not mistakenly load the native 'fs' module
|
2012-01-17 19:43:34 +01:00
|
|
|
// instead of the desired file and that the fs module loads as
|
|
|
|
// expected in node
|
2011-01-25 02:52:38 +01:00
|
|
|
process.chdir(common.fixturesDir + '/test-init-native/');
|
|
|
|
|
2015-03-12 02:16:26 +01:00
|
|
|
child.exec('"' + process.execPath + '" fs', {env: envCopy},
|
2011-10-05 00:08:18 +02:00
|
|
|
function(err, stdout, stderr) {
|
2012-01-17 19:43:34 +01:00
|
|
|
assert.equal(stdout, 'fs loaded successfully',
|
|
|
|
'`node fs` failed!');
|
2011-10-05 00:08:18 +02:00
|
|
|
});
|
2011-01-25 02:52:38 +01:00
|
|
|
}
|
|
|
|
})();
|