-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathGruntfile.js
122 lines (116 loc) · 3.76 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
*
* Copyright 2014-present Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
benchmark: {
all: {
src: ['benchmarks/*.js'],
dest: 'benchmarks.csv'
}
},
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options: {
paths: './lib/',
outdir: './docs/',
tabtospace: 4
}
}
},
jshint: {
files: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'],
options: {
node: true,
mocha: true
}
},
mochaTest: {
unit: {
options: {
reporter: 'spec',
captureFile: 'unit-test-results.txt',
quiet: false,
clearRequireCache: false,
colors: false,
useColors: false
},
src: ['test/unit/**/*.js']
},
integration: {
options: {
reporter: 'spec',
captureFile: 'integration-test-results.txt',
quiet: false,
clearRequireCache: false,
colors: false,
useColors: false
},
src: ['test/integration/**/*.js']
},
security: {
options: {
reporter: 'spec',
captureFile: 'security-test-results.txt',
quiet: false,
clearRequireCache: false,
colors: false,
useColors: false
},
src: ['test/security/**/*.js']
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
}
});
var enable_debug = process.env.RIAK_NODEJS_CLIENT_DEBUG ||
process.env.GRUNT_DEBUG || grunt.option('debug');
if (enable_debug) {
grunt.log.write('enabling test debugging in Mocha');
grunt.config.set('mochaTest.unit.options.require', 'test/debug-log');
grunt.config.set('mochaTest.integration.options.require', 'test/debug-log');
grunt.config.set('mochaTest.security.options.require', 'test/debug-log');
} else {
grunt.config.set('mochaTest.options.require', 'test/disable-log');
}
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.loadNpmTasks('grunt-benchmark');
grunt.registerTask('lint', 'jshint');
grunt.registerTask('unit', function (testSuite) {
if (testSuite) {
testSuite = testSuite.trim();
if (testSuite !== '') {
grunt.config.set('mochaTest.unit.src', ['test/unit/' + testSuite + '/*.js']);
}
}
grunt.task.run(['jshint', 'mochaTest:unit']);
});
grunt.registerTask('integration', ['jshint', 'mochaTest:integration']);
grunt.registerTask('security', ['jshint', 'mochaTest:security']);
grunt.registerTask('default', ['jshint', 'mochaTest:unit', 'mochaTest:integration']);
grunt.registerTask('docs', 'yuidoc');
};