forked from nodejs/node-core-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci_result_parser.test.js
More file actions
284 lines (235 loc) · 9.45 KB
/
ci_result_parser.test.js
File metadata and controls
284 lines (235 loc) · 9.45 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
import { describe, it } from 'node:test';
import assert from 'node:assert';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import {
CITGMComparisonBuild
} from '../../lib/ci/build-types/citgm_comparison_build.js';
import { PRBuild } from '../../lib/ci/build-types/pr_build.js';
import { CommitBuild } from '../../lib/ci/build-types/commit_build.js';
import { BenchmarkRun } from '../../lib/ci/build-types/benchmark_run.js';
import { CITGMBuild } from '../../lib/ci/build-types/citgm_build.js';
import { jobCache } from '../../lib/ci/build-types/job.js';
import TestCLI from '../fixtures/test_cli.js';
import { tmpdir, copyShallow } from '../common.js';
import * as fixtures from '../fixtures/index.js';
function getFixturesDir(prefix) {
const base = fileURLToPath(new URL('../fixtures', import.meta.url));
return path.join(base, ...prefix);
}
describe('Jenkins', () => {
it('should get failures in PR build and commit build', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'js-flake-1'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const request = {
// any attempt to call method on this would throw
};
const prBuild = new PRBuild(cli, request, 15363);
await prBuild.getResults();
const commitBuild = new CommitBuild(cli, request, 19123);
await commitBuild.getResults();
assert.deepStrictEqual(prBuild.commitBuild.failures, commitBuild.failures);
const expectedPrJson = fixtures.readJSON(
...prefix, 'expected-pr.json'
);
assert.deepStrictEqual(prBuild.formatAsJson(), expectedPrJson);
const expectedCommitJson = fixtures.readJSON(
...prefix, 'expected-commit.json'
);
assert.deepStrictEqual(
prBuild.commitBuild.formatAsJson(),
expectedCommitJson
);
assert.deepStrictEqual(prBuild.commitBuild.failures, commitBuild.failures);
const expectedPrMd = fixtures.readFile(
...prefix, 'expected-pr.md'
);
assert.deepStrictEqual(prBuild.formatAsMarkdown(), expectedPrMd);
const expectedCommitMd = fixtures.readFile(
...prefix, 'expected-commit.md'
);
assert.deepStrictEqual(
prBuild.commitBuild.formatAsMarkdown(),
expectedCommitMd
);
});
it('should get successful PR build and commit build', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'success'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const request = {
// any attempt to call method on this would throw
};
const prBuild = new PRBuild(cli, request, 15237);
await prBuild.getResults();
const commitBuild = new CommitBuild(cli, request, 18960);
await commitBuild.getResults();
assert.deepStrictEqual(prBuild.commitBuild.failures, commitBuild.failures);
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(prBuild.commitBuild.failures, expectedJson);
const markdown = commitBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
it('should handle node-test-commit trigger failure', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'trigger-failure'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const request = {
// any attempt to call method on this would throw
};
const prBuild = new PRBuild(cli, request, 15442);
await prBuild.getResults();
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(prBuild.formatAsJson(), expectedJson);
const markdown = prBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
it('should handle git failure', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'git-failure-1'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const request = {
// any attempt to call method on this would throw
};
const prBuild = new PRBuild(cli, request, 15449);
await prBuild.getResults();
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(prBuild.formatAsJson(), expectedJson);
const markdown = prBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
it('should handle no compiler failure', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'no-compiler-error'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const request = {
// any attempt to call method on this would throw
};
const prBuild = new PRBuild(cli, request, 15470);
await prBuild.getResults();
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(prBuild.formatAsJson(), expectedJson);
const markdown = prBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
it('should get benchmark run', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'benchmark-buffer'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const request = {
// any attempt to call method on this would throw
};
const run = new BenchmarkRun(cli, request, 150);
await run.getResults();
const markdown = run.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(run.formatAsJson(), expectedJson);
});
it('should correctly fetch CITGM build results', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'citgm'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const job = { jobid: 2400, noBuild: false };
const citgmBuild = new CITGMBuild(cli, {}, job);
await citgmBuild.getResults();
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(citgmBuild.formatAsJson(), expectedJson);
const markdown = citgmBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
it('should correctly fetch CITGM nobuild job results', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'citgm-nobuild'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const job = { jobid: 866, noBuild: true };
const citgmBuild = new CITGMBuild(cli, {}, job);
await citgmBuild.getResults();
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(citgmBuild.formatAsJson(), expectedJson);
const markdown = citgmBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
it('should correctly fetch CITGM comparison build results', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'citgm-compare'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const job = {
jobid: 2392,
jobid2: 2390,
noBuild: false
};
const comparisonBuild = new CITGMComparisonBuild(cli, {}, job);
await comparisonBuild.getResults();
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(comparisonBuild.formatAsJson(), expectedJson);
const markdown = comparisonBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
it('should correctly fetch CITGM comparison noBuild results', async() => {
tmpdir.refresh();
const prefix = ['jenkins', 'citgm-compare-nobuild'];
const fixturesDir = getFixturesDir(prefix);
copyShallow(fixturesDir, tmpdir.path);
jobCache.dir = tmpdir.path;
jobCache.enable();
const cli = new TestCLI();
const job = {
jobid: 880,
jobid2: 2433,
noBuild: true
};
const comparisonBuild = new CITGMComparisonBuild(cli, {}, job);
await comparisonBuild.getResults();
const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
assert.deepStrictEqual(comparisonBuild.formatAsJson(), expectedJson);
const markdown = comparisonBuild.formatAsMarkdown();
const expected = fixtures.readFile(...prefix, 'expected.md');
assert.strictEqual(markdown, expected);
});
});