forked from mazelab/haraka-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests
76 lines (65 loc) · 2.01 KB
/
run_tests
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
#!/usr/bin/env node
'use strict';
var path = require('path');
var jetpack = require('fs-jetpack');
var jasmine = require('jasmine-node');
process.env.HARAKA = path.dirname(require.resolve("Haraka"));
if (!process.env.HARAKA) {
console.log('Haraka installation not found. Try npm install');
return false;
}
// publish haraka dependencies
try {
require.paths.push(path.join(process.env.HARAKA, 'node_modules'));
}
catch (e) {
process.env.NODE_PATH = process.env.NODE_PATH ?
(process.env.NODE_PATH + ':' + path.join(process.env.HARAKA, 'node_modules'))
:
(path.join(process.env.HARAKA, 'node_modules'));
require('module')._initPaths(); // Horrible hack
}
var parent = jetpack;
var harakaDir = jetpack.cwd(process.env.HARAKA);
var buildDir = parent.dir('.build_test');
var testDir = parent.cwd('spec');
var PluginsDir = parent.cwd('plugins');
jetpack.copy(harakaDir.path(), buildDir.path(), {overwrite: true, matching: './*.js'});
jetpack.copy(testDir.path(), buildDir.path(), {overwrite: true, matching: ['*spec.coffee', '*spec.js']});
jetpack.copy(PluginsDir.path(), buildDir.path(), {overwrite: true, matching: ['./*.js']});
jetpack.copy(parent.path(), buildDir.path(), {overwrite: true, matching: ['./package.json']});
var jasmineOptions = {
specFolders: [buildDir.path()],
isVerbose: false,
showColors: true,
teamcity: false,
useRequireJs: false,
regExpSpec: /.spec\.(js|coffee|litcoffee)$/i,
junitreport: {
report: false,
savePath: './reports/',
useDotNotation: true,
consolidate: true
},
includeStackTrace: true,
growl: false
};
var exitCode = 0;
jasmineOptions.onComplete = function (runner) {
jetpack.remove(buildDir.path());
if (runner.results().failedCount != 0) {
exitCode = 1;
}
process.exit(exitCode);
};
try {
require('coffee-script/register'); // support CoffeeScript >=1.7.0
} catch (e) {
require('coffee-script'); // support CoffeeScript <=1.6.3
}
try {
jasmine.executeSpecsInFolder(jasmineOptions);
} catch (e) {
jasmineOptions.onComplete(e);
throw e;
}