forked from yocontra/node-gdal-next
-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy path_hooks.ts
63 lines (57 loc) · 1.65 KB
/
_hooks.ts
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
import * as gdal from 'gdal-async'
import * as os from 'os'
let noFailNet = function (this: Mocha.Context) {
let test: Mocha.Suite | Mocha.Test | undefined = this.currentTest
while (test) {
if (test.title.match(/w\/Net/)) {
this.retries(3)
}
test = test.parent
}
}
if (!process.env.MOCHA_TEST_NETWORK || +process.env.MOCHA_TEST_NETWORK === 0) {
noFailNet = function (this: Mocha.Context) {
let test: Mocha.Suite | Mocha.Test | undefined = this.currentTest
while (test) {
if (test.title.match(/w\/Net/)) {
console.log('test requires networking, run with MOCHA_TEST_NETWORK=1 npm test to enable:', test.title)
this.skip()
}
test = test.parent
}
}
}
const platformSkip = function (this: Mocha.Context) {
let test: Mocha.Suite | Mocha.Test | undefined = this.currentTest
while (test) {
if (test.title.match(/on Linux/) && os.platform() != 'linux') {
console.log('test requires Linux: ', test.title)
this.skip()
}
test = test.parent
}
}
const bundledSkip = function (this: Mocha.Context) {
let test: Mocha.Suite | Mocha.Test | undefined = this.currentTest
while (test) {
if (test.title.match(/with bundled GDAL/) && !gdal.bundled) {
console.log('test requires bundled version of GDAL: ', test.title)
this.skip()
}
test = test.parent
}
}
const cleanup = () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (gdal as any).drivers
global.gc!()
}
exports.mochaHooks = {
beforeEach: function (done: () => void) {
platformSkip.call(this)
noFailNet.call(this)
bundledSkip.call(this)
done()
},
afterAll: cleanup
}