Repository navigation
Expand file tree
/
Copy pathGruntfile.js
More file actions
113 lines (106 loc) · 3.96 KB
/
Copy pathGruntfile.js
File metadata and controls
113 lines (106 loc) · 3.96 KB
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
'use strict';
process.env.NODE_ENV = 'test';
module.exports = function (grunt) {
const mocha = 'npx mocha --reporter spec --color --exit';
const mochaOutput = {
stdout: true,
stderr: true
};
// imap-core tests that need no MongoDB, Redis or running server
const imapUnitTests = [
'imap-core/test/compress-race-condition-test.js',
'imap-core/test/imap-command-test.js',
'imap-core/test/imap-compile-stream-test.js',
'imap-core/test/imap-connection-test.js',
'imap-core/test/imap-compiler-test.js',
'imap-core/test/imap-indexer-test.js',
'imap-core/test/imap-literal-limit-test.js',
'imap-core/test/imap-line-limit-test.js',
'imap-core/test/imap-parser-test.js',
'imap-core/test/imap-stream-test.js',
'imap-core/test/onconnect-test.js',
'imap-core/test/parse-mime-tree-test.js',
'imap-core/test/proxy-socket-error-test.js',
'imap-core/test/search-test.js',
'imap-core/test/socket-timeout-test.js',
'imap-core/test/tools-test.js'
];
const unitTests = [
'test/certs-test.js',
'test/checkrangequery-test.js',
'test/create-decipher-test.js',
'test/filtering-tools-test.js',
'test/hibp-tools-test.js',
'test/list-headers-test.js',
'test/maildropper-test.js',
'test/message-handler-update-test.js',
'test/mcp-api-client-test.js',
'test/mcp-cli-test.js',
'test/mcp-html-test.js',
'test/mcp-test.js',
'test/mcp-token-handler-test.js',
'test/mcp-tools-test.js',
'test/metrics-config-test.js',
'test/prometheus-test.js',
'test/roles-test.js',
'test/tools-test.js',
'test/user-handler-auth-test.js'
];
// Project configuration.
grunt.initConfig({
eslint: {
all: ['*.js', 'lib/**/*.js', 'imap-core/**/*.js', 'test/**/*.js', 'examples/**/*.js', 'bin/*']
},
wait: {
server: {
options: {
delay: 12 * 1000
}
}
},
shell: {
server: {
command: 'node server.js',
options: {
async: true
}
},
'mocha-imap': {
command: `${mocha} "imap-core/test/**/*-test.js"`,
options: mochaOutput
},
'mocha-imap-unit': {
command: `${mocha} ${imapUnitTests.join(' ')}`,
options: mochaOutput
},
'mocha-pop3': {
command: `${mocha} "test/pop3-*-test.js"`,
options: mochaOutput
},
'mocha-unit': {
command: `${mocha} ${unitTests.join(' ')}`,
options: mochaOutput
},
'mocha-api': {
command: `${mocha} "test/**/*-test.js"`,
options: mochaOutput
},
options: {
stdout: data => console.log(data.toString().trim()),
stderr: data => console.log(data.toString().trim()),
failOnError: true
}
}
});
// Load the plugin(s)
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-wait');
// Tasks
// mocha-imap globs every imap-core test, so the in-process ones must not be listed again here
const mochaTests = ['shell:mocha-imap', 'shell:mocha-pop3', 'shell:mocha-unit', 'shell:mocha-api'];
grunt.registerTask('default', ['eslint', 'shell:server', 'wait:server', ...mochaTests, 'shell:server:kill']);
grunt.registerTask('testonly', ['shell:server', 'wait:server', ...mochaTests, 'shell:server:kill']);
// proto: run all protocol-level tests (IMAP unit + POP3 + unit) without requiring MongoDB/Redis
grunt.registerTask('proto', ['shell:mocha-imap-unit', 'shell:mocha-pop3', 'shell:mocha-unit']);
};