-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
61 lines (41 loc) · 1.27 KB
/
test.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
"use strict";
const path = require("path");
const fs = require("fs");
// Load the configuration
global.CONFIG = require("./config");
// Create some useful global functions
global.getDataFile = function() {
/*
* Function global.getDataFile
* Returns a file from the base data directory
*/
return path.join(__dirname, "data", CONFIG.SERVER.CLIENT_VERSION, ...arguments);
}
global.requireModule = function() {
/*
* Function global.requireModule
* Requires a module from the base source directory
*/
return require(path.join(__dirname, "src", ...arguments));
}
// Load constants
global.CONST = require(getDataFile("constants.json"));
// Requires the prototype modifications
requireModule("__proto__");
if(require.main === module) {
/*
* Function __main__
* Function called when the initialization script is executed
*/
const GameServer = requireModule("gameserver");
// Attach the gameserver to the process and initialize
process.gameServer = new GameServer();
process.gameServer.initialize();
fs.readdirSync("tests").forEach(function(file) {
for(let fn of require(path.join(__dirname, "tests", file))) {
console.log("Running test: %s".format(fn.name));
fn.call();
}
process.gameServer.__scheduleShutdown();
});
}