This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
forked from hsch/node-goog
-
Notifications
You must be signed in to change notification settings - Fork 16
/
compilerCommandLineArgsTests.js
executable file
·83 lines (67 loc) · 2.36 KB
/
compilerCommandLineArgsTests.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
#!/usr/bin/env node
/**
* @fileOverview This test is to try to get the async stuff working better.
* Currently we cannot get proper logs of async tests and we cannot use
* nctest with async tests.
*/
/**
* @private
* @type {nclosure.core}
* @const
*/
var ng_ = require('nclosure').nclosure();
goog.require('goog.testing.jsunit');
goog.require('goog.testing.AsyncTestCase');
var fs = require('fs');
var path = require('path');
var deps = ng_.getPath(__dirname, 'deps.js');
var min = __filename.replace('.js', '.min.js');
function setUp() { clearDepsAndCompiledFile(); };
function tearDownPage() { clearDepsAndCompiledFile(); };
function clearDepsAndCompiledFile() {
if (fs.existsSync(deps)) { fs.unlinkSync(deps); }
if (fs.existsSync(min)) { fs.unlinkSync(min); }
};
function testCompileWithNoArgs() {
runCompilerWithCommandImpl('nccompile ' + __filename, false, false);
};
function testCompileWithNoDepsArg() {
runCompilerWithCommandImpl('nccompile -c ' + __filename, true, false);
};
function testCompileWithDepsOnly() {
runCompilerWithCommandImpl('nccompile -d ' + __filename, false, true);
};
function testCompileWithAll() {
runCompilerWithCommandImpl('nccompile -c -d ' + __filename, true, true);
};
function testVerboseWithAll() {
runCompilerWithCommandImpl('nccompile -v -c -d ' + __filename, true, true);
};
function testVerboseWithNone() {
runCompilerWithCommandImpl('nccompile -v ' + __filename, false, false);
};
function runCompilerWithCommandImpl(cmd, compiledMinFile, depsFile) {
console.error('\t' + cmd);
asyncTestCase.stepTimeout = 10000;
asyncTestCase.waitForAsync();
require('child_process').exec(cmd,
function(err, stdout, stderr) {
if (err) {
assertNull('There were errors running: ' +
cmd + ' message: ' + err.message + '\n' + err.stack, err);
}
assertFilesExist(cmd, compiledMinFile, depsFile);
});
};
function assertFilesExist(cmd, compiledMinFile, depsFile) {
assertEquals('CMD[' + cmd + '] Expected the compiled min file [' +
min + '] to[' +
(compiledMinFile ? 'exist' : 'not exist') + ']',
compiledMinFile, fs.existsSync(min));
assertEquals('CMD[' + cmd + '] Expected the deps file [' +
deps + '] to[' +
(depsFile ? 'exist' : 'not exist') + ']',
depsFile, fs.existsSync(deps));
asyncTestCase.continueTesting();
};
var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();