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') } |
---|
7 | , tasks = ['exec:test1', 'exec:test2', 'exec:test3:42:love', 'exec:test4']; |
---|
8 | |
---|
9 | grunt.tasks(tasks, opts, function() { |
---|
10 | var tests = [ |
---|
11 | { name: 'test1', expected: 'bruce willis was dead\n' } |
---|
12 | , { name: 'test2' , expected: 'grunt@' + grunt.version + '\n' } |
---|
13 | , { |
---|
14 | name: 'test3' |
---|
15 | , expected: [ |
---|
16 | 'the answer to life is 42', 'thoughts on tacos? love', '' |
---|
17 | ].join('\n') |
---|
18 | } |
---|
19 | , { |
---|
20 | name: 'test4' |
---|
21 | , expected:'you can use callback, and error, stdout, stderr can be used as arguments\n' |
---|
22 | } |
---|
23 | ] |
---|
24 | , outputPath; |
---|
25 | |
---|
26 | tests.forEach(function(test) { |
---|
27 | outputPath = path.join(testDir, test.name); |
---|
28 | assert.equal(fs.readFileSync(outputPath, 'utf8'), test.expected); |
---|
29 | |
---|
30 | // clean up |
---|
31 | fs.unlinkSync(outputPath); |
---|
32 | |
---|
33 | grunt.log.ok(test.name +' passed'); |
---|
34 | }); |
---|
35 | }); |
---|