Rev | Line | |
---|
[484] | 1 | var grunt = require('grunt') |
---|
| 2 | , path = require('path') |
---|
| 3 | , fs = require('fs') |
---|
| 4 | , assert = require('assert') |
---|
| 5 | , testDir = path.join(process.cwd(), 'test') |
---|
| 6 | , opts = { gruntfile: path.join(testDir, 'Gruntfile.js') } |
---|
[516] | 7 | , tasks = [ |
---|
| 8 | 'exec:test1' |
---|
| 9 | , 'exec:test2' |
---|
| 10 | , 'exec:test3:42:love' |
---|
| 11 | , 'exec:test4' |
---|
| 12 | , 'exec:test5' |
---|
| 13 | , 'exec:test6' |
---|
| 14 | , 'exec:test7' |
---|
| 15 | ]; |
---|
[484] | 16 | |
---|
| 17 | grunt.tasks(tasks, opts, function() { |
---|
| 18 | var tests = [ |
---|
| 19 | { name: 'test1', expected: 'bruce willis was dead\n' } |
---|
| 20 | , { name: 'test2' , expected: 'grunt@' + grunt.version + '\n' } |
---|
| 21 | , { |
---|
| 22 | name: 'test3' |
---|
| 23 | , expected: [ |
---|
| 24 | 'the answer to life is 42', 'thoughts on tacos? love', '' |
---|
| 25 | ].join('\n') |
---|
| 26 | } |
---|
| 27 | , { |
---|
| 28 | name: 'test4' |
---|
| 29 | , expected:'you can use callback, and error, stdout, stderr can be used as arguments\n' |
---|
| 30 | } |
---|
[516] | 31 | , { name: 'test7', expected: 'you don\'t even need an object\n' } |
---|
[484] | 32 | ] |
---|
| 33 | , outputPath; |
---|
| 34 | |
---|
| 35 | tests.forEach(function(test) { |
---|
| 36 | outputPath = path.join(testDir, test.name); |
---|
| 37 | assert.equal(fs.readFileSync(outputPath, 'utf8'), test.expected); |
---|
| 38 | |
---|
| 39 | // clean up |
---|
| 40 | fs.unlinkSync(outputPath); |
---|
| 41 | |
---|
| 42 | grunt.log.ok(test.name +' passed'); |
---|
| 43 | }); |
---|
| 44 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.