-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmake.js
106 lines (99 loc) · 3.68 KB
/
make.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
/*
* Copyright 2024 XWiki SAS
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
var Glue = require('gluejs');
var Fs = require('fs');
var nThen = require('nthen');
//var Os = require('os');
var cycles = 1;
var tests = [];
var timeOne;
nThen(function (waitFor) {
var g = new Glue();
g.basepath('./client');
g.main('ChainPad.js');
g.include('./ChainPad.js');
g.include('./Message.js');
g.include('./SHA256.js');
g.include('./Common.js');
g.include('./Patch.js');
g.include('./Operation.js');
g.include('./transform/TextTransformer.js');
g.include('./transform/NaiveJSONTransformer.js');
g.include('./transform/SmartJSONTransformer.js');
g.include('./Diff.js');
g.include('./sha256.js');
g.include('./sha256/exports.js');
g.include('./sha256/hash.js');
g.include('./sha256/sha256.asm.js');
g.include('./sha256/sha256.js');
g.include('./sha256/utils.js');
g.include('../node_modules/json.sortify/dist/JSON.sortify.js');
g.include('../node_modules/fast-diff/diff.js');
g.set('reset-exclude', true);
g.set('verbose', true);
g.set('umd', true);
g.export('ChainPad');
//g.set('command', 'uglifyjs --no-copyright --m "toplevel"');
g.render(waitFor(function (err, txt) {
if (err) { throw err; }
// make an anonymous define, don't insist on your name!
txt = txt.replace(
'"function"==typeof define&&define.amd&&define(f,function',
'"function"==typeof define&&define.amd&&define(function'
);
Fs.writeFile('./chainpad.js', txt, waitFor());
}));
}).nThen(function (waitFor) {
timeOne = new Date().getTime();
if (process.argv.indexOf('--cycles') !== -1) {
cycles = process.argv[process.argv.indexOf('--cycles')+1];
console.log("Running [" + cycles + "] test cycles");
}
var nt = nThen;
['./client/', './client/transform/'].forEach(function (path) {
Fs.readdir(path, waitFor(function (err, ret) {
if (err) { throw err; }
ret.forEach(function (file) {
if (/_test\.js$/.test(file)) {
nt = nt(function (waitFor) {
tests.push(file);
var test = require(path + file);
console.log("Running Test " + file);
test.main(cycles, waitFor());
}).nThen;
}
});
nt(waitFor());
}));
});
}).nThen(function () {
console.log("Tests passed.");
console.log('in ' + (new Date().getTime() - timeOne));
}).nThen(function () {
var g = new Glue();
g.basepath('./client');
g.main('AllTests.js');
g.include('./');
g.include('../node_modules/nthen/index.js');
g.include('../node_modules/fast-diff/diff.js');
g.remap('testNames', JSON.stringify(tests));
g.export('AllTests');
//g.set('command', 'uglifyjs --no-copyright --m "toplevel"');
g.render(Fs.createWriteStream('./alltests.js'));
});