File size: 1,968 Bytes
5c2ed06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
'use strict';

require('child_process').execSync('node "' + __dirname + '/../build"');
const path = require('path');
const fs = require('fs');

const noop = () => {};

// Load and override configuration before starting the server
let config;
try {
	require.resolve('../config/config');
} catch (err) {
	if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ENOENT') throw err; // Should never happen

	console.log("config.js doesn't exist - creating one with default settings...");
	fs.writeFileSync(
		path.resolve(__dirname, '../config/config.js'),
		fs.readFileSync(path.resolve(__dirname, '../config/config-example.js'))
	);
} finally {
	config = require('../config/config');
}
Object.assign(config, require('../config/config-example'));

// Actually crash if we crash
config.crashguard = false;
// Don't allow config to be overridden while test is running
config.watchconfig = false;
// Don't try to write to file system
config.nofswriting = true;
// allow renaming without a token
config.noguestsecurity = true;
// Test a normal ladder
config.fakeladder = false;
// Don't log monitor messages to the console (necessary so that chat monitor tests don't clog up stdout)
config.loglevel = 3;

require('./../dist/lib/process-manager').ProcessManager.disabled = true;

// stop chatrooms from loading through modifying the require cache
try {
	const chatrooms = require('../config/chatrooms.json');
	chatrooms.splice(0, chatrooms.length);
} catch {}

// Don't create a REPL
require('../dist/lib/repl').Repl.start = noop;

// Start the server.
// NOTE: This used "server" before when we needed "server"
require('../dist/server');

LoginServer.disabled = true;
Ladders.disabled = true;

before('initialization', function () {
	this.timeout(0); // Remove timeout limitation
	process.on('unhandledRejection', err => {
		// I'd throw the err, but we have a heisenbug on our hands and I'd
		// rather not have it screw with Travis in the interim
		console.log(err);
	});
});