Commit 24f0725a by Andrew Nesbitt

Merge pull request #160 from LaurentGoderre/fix-tests-windows

Fixed the test suite in Windows
parents a3c1124c 45acd4e0
...@@ -20,13 +20,11 @@ function render(options, emitter) { ...@@ -20,13 +20,11 @@ function render(options, emitter) {
if (err) return emitter.emit('error', ('Error: ' + err).red); if (err) return emitter.emit('error', ('Error: ' + err).red);
emitter.emit('warn', ('Wrote CSS to ' + options.outFile).green); emitter.emit('warn', ('Wrote CSS to ' + options.outFile).green);
emitter.emit('write', err, options.outFile, css); emitter.emit('write', err, options.outFile, css);
if (options.stdout) {
emitter.emit('log', css);
}
emitter.emit('render', css);
}); });
if (options.stdout) {
emitter.emit('log', css);
}
emitter.emit('render', css);
}, },
error: function(error) { error: function(error) {
emitter.emit('error', error); emitter.emit('error', error);
......
...@@ -2,10 +2,10 @@ var path = require('path'), ...@@ -2,10 +2,10 @@ var path = require('path'),
assert = require('assert'), assert = require('assert'),
fs = require('fs'), fs = require('fs'),
exec = require('child_process').exec, exec = require('child_process').exec,
sass = require(path.join(__dirname, '..', 'sass')), sass = require('../sass'),
cli = require(path.join(__dirname, '..', 'lib', 'cli')), cli = require('../lib/cli'),
cliPath = path.resolve(__dirname, '..', 'bin', 'node-sass'), cliPath = path.resolve(__dirname, '../bin/node-sass'),
sampleFilename = path.resolve(__dirname, 'sample.scss'); sampleFilename = path.resolve(__dirname, 'sample.scss');
var expectedSampleCompressed = '#navbar {width:80%;height:23px;}\ var expectedSampleCompressed = '#navbar {width:80%;height:23px;}\
...@@ -27,7 +27,7 @@ var expectedSampleNoComments = '#navbar {\n\ ...@@ -27,7 +27,7 @@ var expectedSampleNoComments = '#navbar {\n\
describe('cli', function() { describe('cli', function() {
it('should print help when run with no arguments', function(done) { it('should print help when run with no arguments', function(done) {
exec(cliPath, function(err, stdout, stderr) { exec('node ' + cliPath, function(err, stdout, stderr) {
done(assert(stderr.indexOf('Compile .scss files with node-sass') === 0)); done(assert(stderr.indexOf('Compile .scss files with node-sass') === 0));
}); });
}); });
...@@ -35,7 +35,7 @@ describe('cli', function() { ...@@ -35,7 +35,7 @@ describe('cli', function() {
it('should compile sample.scss as sample.css', function(done) { it('should compile sample.scss as sample.css', function(done) {
var resultPath = path.join(__dirname, 'sample.css'); var resultPath = path.join(__dirname, 'sample.css');
exec(cliPath + ' ' + sampleFilename, { exec('node ' + cliPath + ' ' + sampleFilename, {
cwd: __dirname cwd: __dirname
}, function(err, stdout, stderr) { }, function(err, stdout, stderr) {
...@@ -47,9 +47,9 @@ describe('cli', function() { ...@@ -47,9 +47,9 @@ describe('cli', function() {
}); });
it('should compile sample.scss to ../out.css', function(done) { it('should compile sample.scss to ../out.css', function(done) {
var resultPath = path.resolve(__dirname, '..', 'out.css'); var resultPath = path.resolve(__dirname, '../out.css');
exec(cliPath + ' ' + sampleFilename + ' ../out.css', { exec('node ' + cliPath + ' ' + sampleFilename + ' ../out.css', {
cwd: __dirname cwd: __dirname
}, function(err, stdout, stderr) { }, function(err, stdout, stderr) {
...@@ -62,38 +62,38 @@ describe('cli', function() { ...@@ -62,38 +62,38 @@ describe('cli', function() {
it('should compile with --include-path option', function(done){ it('should compile with --include-path option', function(done){
var emitter = cli([ var emitter = cli([
'--include-path', path.join(__dirname, '/lib'), '--include-path', path.join(__dirname, 'lib'),
'--include-path', path.join(__dirname, '/functions'), '--include-path', path.join(__dirname, 'functions'),
path.join(__dirname, '/include_path.scss') path.join(__dirname, 'include_path.scss')
]); ]);
emitter.on('error', done); emitter.on('error', done);
emitter.on('render', function(css){ emitter.on('render', function(css){
assert.equal(css.trim(), 'body {\n background: red;\n color: blue; }'); assert.equal(css.trim(), 'body {\n background: red;\n color: blue; }');
fs.unlink(process.cwd() + '/include_path.css', done); fs.unlink(path.resolve(process.cwd(), 'include_path.css'), done);
}); });
}); });
it('should compile with the --output-style', function(done){ it('should compile with the --output-style', function(done){
var emitter = cli(['--output-style', 'compressed', __dirname + '/sample.scss']); var emitter = cli(['--output-style', 'compressed', path.join(__dirname, 'sample.scss')]);
emitter.on('error', done); emitter.on('error', done);
emitter.on('render', function(css){ emitter.on('render', function(css){
assert.equal(css, expectedSampleCompressed); assert.equal(css, expectedSampleCompressed);
fs.unlink(process.cwd() + '/sample.css', done); fs.unlink(path.resolve(process.cwd(), 'sample.css'), done);
}); });
}); });
it('should compile with the --source-comments option', function(done){ it('should compile with the --source-comments option', function(done){
var emitter = cli(['--source-comments', 'none', __dirname + '/sample.scss']); var emitter = cli(['--source-comments', 'none', path.join(__dirname, 'sample.scss')]);
emitter.on('error', done); emitter.on('error', done);
emitter.on('render', function(css){ emitter.on('render', function(css){
assert.equal(css, expectedSampleNoComments); assert.equal(css, expectedSampleNoComments);
fs.unlink(process.cwd() + '/sample.css', done); fs.unlink(path.resolve(process.cwd(), 'sample.css'), done);
}); });
}); });
it('should write the output to the file specified with the --output option', function(done){ it('should write the output to the file specified with the --output option', function(done){
var resultPath = path.resolve(__dirname, '..', 'output.css'); var resultPath = path.join(__dirname, '../output.css');
var emitter = cli(['--output', resultPath, __dirname + '/sample.scss']); var emitter = cli(['--output', resultPath, path.join(__dirname, 'sample.scss')]);
emitter.on('error', done); emitter.on('error', done);
emitter.on('write', function(css){ emitter.on('write', function(css){
fs.exists(resultPath, function(exists) { fs.exists(resultPath, function(exists) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment