Repository navigation
Expand file tree
/
Copy pathAgentProgressRenderer.test.ts
More file actions
1884 lines (1769 loc) · 84 KB
/
Copy pathAgentProgressRenderer.test.ts
File metadata and controls
1884 lines (1769 loc) · 84 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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import {
DAEMON_PROTOCOL_VERSION,
type DaemonEventType,
type IDaemonContinuingOperations,
type IDaemonEventEnvelope
} from '@rushstack/rush-daemon-protocol';
import { AgentProgressRenderer } from '../AgentProgressRenderer';
import {
RESUBMITTED_PHASE,
createDaemonRequestNoticeHandlers,
type IDaemonRequestNoticeHandlers
} from '../daemonRestartNotice';
import { withNativeLockWaitNotices, type INativeLockWaitNoticeHandlers } from '../nativeLockWaitNotice';
function event(type: DaemonEventType, payload: unknown): IDaemonEventEnvelope {
return {
eventId: 'event',
sessionId: 'session',
sequence: 1,
timestamp: new Date().toISOString(),
protocolVersion: DAEMON_PROTOCOL_VERSION,
source: { packageName: 'test', packageVersion: '1.0.0' },
privacy: 'public',
required: false,
type,
payload
};
}
const ANSI_ESCAPE: RegExp = new RegExp(`${String.fromCharCode(27)}\\[[0-9;?]*[A-Za-z]`, 'g');
interface ITestRenderer {
renderer: AgentProgressRenderer;
output: string[];
clock: { ms: number };
/** All output, split into lines. */
lines(): string[];
}
function createRenderer(isTTY: boolean, commandName: string = 'build', columns: number = 60): ITestRenderer {
const output: string[] = [];
const clock: { ms: number } = { ms: 0 };
const renderer: AgentProgressRenderer = new AgentProgressRenderer({
commandName,
isTTY,
columns,
write: (text: string) => output.push(text),
now: () => clock.ms,
startTimeMs: 0
});
return { renderer, output, clock, lines: () => output.join('').split('\n').slice(0, -1) };
}
function registered(operationId: string, silent: boolean = false): IDaemonEventEnvelope {
return event('operationRegistered', { operationId, silent });
}
function status(
operationId: string,
value: string,
logFilePath?: string,
commandKind?: unknown
): IDaemonEventEnvelope {
return event('operationStatusChanged', {
operationId,
previousStatus: 'READY',
status: value,
logFilePath,
commandKind
});
}
function header(
operationId: string,
completedOperations: number,
totalOperations: number
): IDaemonEventEnvelope {
return event('extension', {
name: 'rushd.operation-header',
data: { operationId, completedOperations, totalOperations }
});
}
function streamClosed(operationId: string): IDaemonEventEnvelope {
return event('extension', { name: 'rushd.operation-stream-closed', data: { operationId } });
}
function fail(renderer: AgentProgressRenderer, operationId: string, errorLines: ReadonlyArray<string>): void {
renderer.onEvent(status(operationId, 'EXECUTING'));
renderer.onLog(Buffer.from(errorLines.map((line) => `${line}\n`).join('')), operationId, 'stderr');
renderer.onEvent(status(operationId, 'FAILURE', `/repo/${operationId.split(' ')[0]}/rush-logs/x.log`));
}
describe(AgentProgressRenderer.name, () => {
it('writes one line when the request is sent and a summary line for a successful build (pipe)', () => {
const { renderer, output, clock, lines } = createRenderer(false);
renderer.start();
expect(output).toEqual([]);
renderer.onRequestSent();
expect(output).toEqual([
'rush build · 0.0s · sent to rushd; preparing the workspace graph (status at least every 25s)\n'
]);
renderer.onEvent(registered('a (build)'));
renderer.onEvent(registered('b (build)'));
renderer.onEvent(registered('hidden', true));
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('noise\n'), 'a (build)', 'stdout');
clock.ms = 2500;
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.onEvent(status('hidden', 'SUCCESS'));
renderer.onEvent(status('b (build)', 'SKIPPED'));
clock.ms = 3000;
expect(renderer.finish({ exitCode: 0 })).toBe(false);
renderer.dispose();
expect(lines()).toEqual([
'rush build · 0.0s · sent to rushd; preparing the workspace graph (status at least every 25s)',
'rush build: SUCCESS 2/2 operations (1 success, 1 up to date) in 3.0s'
]);
});
it('reports an up-to-date request instead of printing nothing', () => {
const { renderer, output } = createRenderer(false);
renderer.finish({ exitCode: 0 });
expect(output).toEqual(['rush build: SUCCESS up to date (no operations needed) in 0.0s\n']);
});
it('tells an empty selection apart from a request whose operations were all up to date', () => {
const hot: ITestRenderer = createRenderer(false);
// The daemon announces retained operations as silent and reports their retained results.
hot.renderer.onEvent(registered('a (build)', true));
hot.renderer.onEvent(registered('b (build)', true));
hot.renderer.finish({
exitCode: 0,
operationResults: [
{ operationId: 'a (build)', status: 'SUCCESS' },
{ operationId: 'b (build)', status: 'FROM CACHE' }
]
});
expect(hot.output).toEqual(['rush build: SUCCESS up to date (no operations needed) in 0.0s\n']);
const empty: ITestRenderer = createRenderer(false);
empty.renderer.finish({ exitCode: 0, operationResults: [] });
expect(empty.output).toEqual([
'rush build: SUCCESS 0 operations in 0.0s · the selection parameters did not match any projects\n'
]);
});
it('reports a failed operation with its log file and an excerpt as soon as it fails', () => {
const { renderer, lines } = createRenderer(false);
fail(
renderer,
'p05 (build)',
Array.from({ length: 20 }, (unused, i) => `error ${i}`)
);
expect(lines()).toHaveLength(9);
renderer.onEvent(status('p06 (build)', 'BLOCKED'));
renderer.finish({ exitCode: 1 });
expect(lines()).toEqual([
'failed: p05 (build) · full log: /repo/p05/rush-logs/x.log',
' error 0',
' error 1',
' error 2',
' error 3',
' error 4',
' error 5',
' error 18',
' error 19',
'rush build: FAILURE 2/2 operations (1 failure, 1 blocked) in 0.0s · failed: p05 (build)'
]);
});
it('says which operations continue in rushd after a failure that the daemon reported early', () => {
const operationIds: ReadonlyArray<string> = ['a (build)', 'b (build)', 'c (build)', 'd (build)'];
const finishWith = (unfinished: ReadonlyArray<[string, string]>, exitCode: number = 1): string[] => {
const { renderer, lines } = createRenderer(false);
for (const operationId of operationIds) renderer.onEvent(registered(operationId));
fail(renderer, 'b (build)', ['error']);
renderer.onEvent(status('a (build)', 'BLOCKED'));
renderer.finish({
exitCode,
operationResults: [
{ operationId: 'a (build)', status: 'BLOCKED' },
{ operationId: 'b (build)', status: 'FAILURE' },
...unfinished.map(([operationId, value]) => ({ operationId, status: value }))
]
});
return lines();
};
expect(finishWith([['c (build)', 'EXECUTING']]).pop()).toBe(
'rush build: FAILURE 2/4 operations (1 failure, 1 blocked) in 0.0s · failed: b (build)' +
' · 1 independent operation continues in rushd: c (build)'
);
expect(
finishWith([
['c (build)', 'EXECUTING'],
['d (build)', 'QUEUED']
]).pop()
).toMatch(
/ · failed: b \(build\) · 2 independent operations continue in rushd: c \(build\), d \(build\)$/
);
// Like a live row, the line names only the first few.
expect(
finishWith([
['c (build)', 'EXECUTING'],
['d (build)', 'QUEUED'],
['e (build)', 'WAITING'],
['f (build)', 'READY'],
['g (build)', 'EXECUTING']
]).pop()
).toMatch(
/ · 5 independent operations continue in rushd: c \(build\), d \(build\), e \(build\) \+2 more$/
);
// The names come in name order, as the daemon's queue positions give them, whatever the result's order.
expect(
finishWith([
['g (build)', 'EXECUTING'],
['f (build)', 'READY'],
['e (build)', 'WAITING'],
['d (build)', 'QUEUED'],
['c (build)', 'EXECUTING']
]).pop()
).toMatch(
/ · 5 independent operations continue in rushd: c \(build\), d \(build\), e \(build\) \+2 more$/
);
expect(finishWith([['c (build)', 'SUCCESS']]).pop()).toMatch(/ · failed: b \(build\)$/);
expect(finishWith([['c (build)', 'EXECUTING']], 0).pop()).not.toContain('continue');
});
it('keeps failure diagnostics when successful operations wrote stderr first', () => {
const { renderer, output } = createRenderer(false);
renderer.onEvent(status('noisy (build)', 'EXECUTING'));
for (let i: number = 0; i < 20; i++) {
renderer.onLog(Buffer.from(`warning ${i}\n`), 'noisy (build)', 'stderr');
}
renderer.onEvent(status('noisy (build)', 'SUCCESS WITH WARNINGS'));
fail(renderer, 'broken (build)', ['the real error']);
renderer.finish({ exitCode: 1 });
const text: string = output.join('');
expect(text).toContain(
'failed: broken (build) · full log: /repo/broken/rush-logs/x.log\n the real error\n'
);
expect(text).not.toContain('warning 1');
expect(text).toMatch(/· failed: broken \(build\)\n$/);
});
it('reports unchanged operations as up to date, whether the daemon says SKIPPED or NO OP', () => {
const { renderer, output } = createRenderer(false);
renderer.onEvent(status('a (build)', 'NO OP'));
renderer.onEvent(status('b (build)', 'SKIPPED'));
renderer.onEvent(status('c (build)', 'FROM CACHE'));
renderer.finish({ exitCode: 0 });
expect(output[output.length - 1]).toBe(
'rush build: SUCCESS 3/3 operations (1 from cache, 2 up to date) in 0.0s\n'
);
});
it('counts ABORTED operations as finished', () => {
const { renderer, output } = createRenderer(false);
renderer.onEvent(registered('a (build)'));
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onEvent(status('a (build)', 'ABORTED'));
renderer.finish({ exitCode: 1 });
expect(output[output.length - 1]).toBe('rush build: FAILURE 1/1 operations (1 aborted) in 0.0s\n');
});
it('reports a cancelled command as CANCELLED, without the output of the interrupted operations', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(registered('a (build)'));
renderer.onEvent(registered('b (build)'));
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('error: interrupted by SIGINT\n'), 'a (build)', 'stderr');
renderer.finish({
exitCode: 130,
cancelled: true,
operationResults: [
{ operationId: 'a (build)', status: 'ABORTED' },
{ operationId: 'b (build)', status: 'ABORTED' }
]
});
expect(lines()).toEqual(['rush build: CANCELLED 2/2 operations (2 aborted) in 0.0s']);
});
it('still reports the failures of a cancelled command', () => {
const { renderer, lines } = createRenderer(false);
fail(renderer, 'a (build)', ['src/a.ts(1,1): error TS2322: bad']);
renderer.finish({ exitCode: 130, cancelled: true });
expect(lines().slice(-3)).toEqual([
'failed: a (build) · full log: /repo/a/rush-logs/x.log',
' src/a.ts(1,1): error TS2322: bad',
'rush build: CANCELLED 1/1 operations (1 failure) in 0.0s · failed: a (build)'
]);
});
it('says at once that it waits for rushd to stop a cancelled request, and whether rushd confirmed', () => {
const confirmed: ITestRenderer = createRenderer(false);
confirmed.renderer.onEvent(registered('a (build)'));
confirmed.renderer.onEvent(status('a (build)', 'EXECUTING'));
confirmed.clock.ms = 7_600;
confirmed.renderer.onCancelRequested(5_000);
expect(confirmed.lines()).toEqual([
'rush build 0/1 · 7.6s · cancelling; waiting up to 5s for rushd to stop the request'
]);
// Written once, and the operations that rushd stops do not make the request look as if it runs on.
confirmed.renderer.onCancelRequested(5_000);
confirmed.renderer.onEvent(status('a (build)', 'ABORTED'));
confirmed.clock.ms = 8_100;
confirmed.renderer.finish({ exitCode: 130, cancelled: true });
expect(confirmed.lines()).toEqual([
'rush build 0/1 · 7.6s · cancelling; waiting up to 5s for rushd to stop the request',
'rush build: CANCELLED 1/1 operations (1 aborted) in 8.1s'
]);
const unconfirmed: ITestRenderer = createRenderer(false);
unconfirmed.renderer.onCancelRequested(5_000);
unconfirmed.clock.ms = 5_000;
unconfirmed.renderer.finish({ exitCode: 130, cancelled: true, stopUnconfirmed: true });
expect(unconfirmed.lines()).toEqual([
'rush build · 0.0s · cancelling; waiting up to 5s for rushd to stop the request',
'rush build: CANCELLED in 5.0s · rushd did not confirm that the request stopped; it may still be stopping'
]);
});
it('keeps showing on a TTY that it cancels', () => {
jest.useFakeTimers();
try {
const { renderer, output } = createRenderer(true, 'build', 120);
const firstRow = (): string => output[output.length - 1].replace(ANSI_ESCAPE, '').split('\n')[0];
renderer.start();
renderer.onEvent(registered('a (build)'));
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onCancelRequested(5_000);
// Repainted at once, rather than on the next tick of the timer.
expect(firstRow()).toBe(
'⠙ rush build 0/1 · 0.0s · cancelling; waiting up to 5s for rushd to stop the request'
);
renderer.onEvent(status('a (build)', 'ABORTED'));
renderer.onQueuePosition(1);
jest.advanceTimersByTime(100);
// Neither the operation that rushd stopped nor a queue position makes the request look as if it runs on.
expect(firstRow()).toBe(
'⠹ rush build 1/1 · 0.0s · cancelling; waiting up to 5s for rushd to stop the request'
);
renderer.dispose();
} finally {
jest.useRealTimers();
}
});
it('applies final statuses from the daemon result that no event reported', () => {
const { renderer, lines } = createRenderer(false);
const reason: string =
'The Rush daemon was shut down (idle timeout) while this request was running; re-run the command.';
renderer.onEvent(registered('a (build)'));
renderer.onEvent(registered('b (build)'));
renderer.onEvent(registered('silent (build)', true));
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.onEvent(status('b (build)', 'EXECUTING'));
const reported: boolean = renderer.finish({
exitCode: 1,
errorMessage: reason,
operationResults: [
{ operationId: 'a (build)', status: 'SUCCESS' },
{ operationId: 'b (build)', status: 'ABORTED' },
{ operationId: 'silent (build)', status: 'ABORTED' },
// The result lists silent operations too; one that no event announced is not counted.
{ operationId: 'unannounced (build)', status: 'NO OP' }
]
});
expect(reported).toBe(true);
expect(lines().slice(-1)).toEqual([
`rush build: FAILURE 2/2 operations (1 aborted, 1 success) in 0.0s · ${reason}`
]);
});
it("prints a failed operation's error from the daemon result when the operation wrote no output", () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(registered('a (build)'));
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.finish({
exitCode: 1,
operationResults: [{ operationId: 'a (build)', status: 'FAILURE', errorMessage: 'spawn heft ENOENT' }]
});
expect(lines().slice(-3)).toEqual([
'failed: a (build)',
' spawn heft ENOENT',
'rush build: FAILURE 1/1 operations (1 failure) in 0.0s · failed: a (build)'
]);
});
it('tells a repeated finish whether its error message was already reported in full', () => {
const { renderer, output } = createRenderer(false);
const message: string = 'Daemon rejected the request (routingFailed): Another Rush command is running.';
expect(renderer.finish({ exitCode: 1, errorMessage: message })).toBe(true);
expect(renderer.finish({ exitCode: 1, errorMessage: message })).toBe(true);
expect(renderer.finish({ exitCode: 1, errorMessage: 'another message' })).toBe(false);
expect(output).toEqual([`rush build: FAILURE in 0.0s · ${message}\n`]);
});
it('keeps the legacy "daemon admission failed (<code>)" string in the summary line', () => {
const timeout: ITestRenderer = createRenderer(false);
const message: string =
'The request was not admitted within 30000ms while waiting for workspace admission. ' +
'Use --wait-timeout <seconds> or RUSH_DAEMON_QUEUE_TIMEOUT_SECONDS to wait longer.';
expect(
timeout.renderer.finish({ exitCode: 1, admissionErrorCode: 'wait-timeout', errorMessage: message })
).toBe(true);
expect(timeout.output).toEqual([
`rush build: FAILURE in 0.0s · daemon admission failed (wait-timeout): ${message}\n`
]);
const noWait: ITestRenderer = createRenderer(false);
noWait.renderer.finish({
exitCode: 1,
admissionErrorCode: 'no-wait',
errorMessage: 'The workspace is busy.'
});
expect(noWait.output).toEqual([
'rush build: FAILURE in 0.0s · daemon admission failed (no-wait): The workspace is busy.\n'
]);
// A request aborted while it waited, for example by a daemon shutdown, is not a busy workspace.
const aborted: ITestRenderer = createRenderer(false);
aborted.renderer.finish({
exitCode: 1,
admissionErrorCode: 'aborted',
errorMessage: 'The Rush daemon was shut down.'
});
expect(aborted.output).toEqual(['rush build: FAILURE in 0.0s · The Rush daemon was shut down.\n']);
});
it('writes the reason for an admission failure in full however long it is, so the caller adds nothing', () => {
// A restart drain that timed out behind a rushx script after it waived time: 350 characters.
const message: string =
'The request was not admitted before the daemon could restart for its environment, which waits for the ' +
'requests that the daemon is serving to finish, including a rushx script that may not exit until it is ' +
'stopped; 61.8s spent waiting for requests that were already running did not count. Stop the script, ' +
'or use --wait-timeout <seconds> to wait longer.';
expect(message.length).toBeGreaterThan(300);
const { renderer, output } = createRenderer(false);
expect(renderer.finish({ exitCode: 1, admissionErrorCode: 'wait-timeout', errorMessage: message })).toBe(
true
);
expect(output).toEqual([
`rush build: FAILURE in 0.0s · daemon admission failed (wait-timeout): ${message}\n`
]);
});
it('clips any other single-line error message that is too long, and leaves it to the caller', () => {
const message: string = `Rush failed: ${'x'.repeat(400)} (end)`;
const { renderer, output } = createRenderer(false);
expect(renderer.finish({ exitCode: 1, errorMessage: message })).toBe(false);
expect(output).toHaveLength(1);
expect(output[0]).toMatch(/^rush build: FAILURE in 0\.0s · Rush failed: x+…x+ \(end\)\n$/);
expect(output[0].length).toBeLessThan(message.length);
});
it('writes the final line at most once and nothing after it', () => {
const { renderer, output } = createRenderer(false);
expect(renderer.finish({ exitCode: 1, errorMessage: 'daemon rejected the request (x)' })).toBe(true);
expect(renderer.finish({ exitCode: 1, errorMessage: 'again' })).toBe(false);
renderer.onQueuePosition(3);
renderer.onEvent(status('a (build)', 'FAILURE'));
renderer.dispose();
expect(output).toEqual(['rush build: FAILURE in 0.0s · daemon rejected the request (x)\n']);
});
it('writes the further lines of a multi-line error message before the summary line', () => {
const { renderer, output } = createRenderer(false);
expect(renderer.finish({ exitCode: 1, errorMessage: 'first line\n\nsecond line\n' })).toBe(true);
expect(output).toEqual([' second line\nrush build: FAILURE in 0.0s · first line\n']);
});
it('keeps the age of a daemon that did not answer, and that Rush was not run in-process, whole', () => {
// As the client words it for a stopped daemon, with a socket path as long as a Unix socket path can be.
const socketPath: string = `/${'s'.repeat(100)}.sock`;
const description: string =
`The daemon, rushd (PID 4194304), did not answer at ${socketPath}: it is stopped (state T), ` +
'for example by SIGSTOP, and it started 59 min ago.';
const notRun: string =
'Rush was not run in-process, where it would compete with that daemon for the repository.';
const hint: string = 'Resume it with "kill -CONT 4194304"; it then serves the next command.';
const { renderer, output } = createRenderer(false);
expect(renderer.finish({ exitCode: 1, errorMessage: [description, notRun, hint].join('\n') })).toBe(true);
expect(output.join('').split('\n')).toEqual([
` ${notRun}`,
` ${hint}`,
`rush build: FAILURE in 0.0s · ${description}`,
''
]);
});
it('elides the middle of an error message with thousands of lines and keeps its last lines', () => {
const { renderer, output } = createRenderer(false);
const diagnostics: string[] = Array.from({ length: 1745 }, (unused, index) => `debug line ${index}`);
const message: string = [
'Daemon rejected the request (invalidRequest): Incremental strategy: cache restoration',
...diagnostics,
'The project name "@x/nope" passed to "--to" does not exist in rush.json.',
'An error occurred.'
].join('\n');
expect(renderer.finish({ exitCode: 1, errorMessage: message })).toBe(true);
expect(output.join('').split('\n')).toEqual([
' debug line 0',
' debug line 1',
' … 1740 more lines …',
' debug line 1742',
' debug line 1743',
' debug line 1744',
' The project name "@x/nope" passed to "--to" does not exist in rush.json.',
' An error occurred.',
'rush build: FAILURE in 0.0s · Daemon rejected the request (invalidRequest): Incremental strategy: cache restoration',
''
]);
});
it('reports the queue in the summary line rather than in a line of its own (pipe)', () => {
const { renderer, output, clock } = createRenderer(false);
clock.ms = 100;
renderer.onQueuePosition(2);
clock.ms = 5000;
renderer.onQueuePosition(1);
expect(output).toEqual([]);
clock.ms = 15_000;
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.finish({ exitCode: 0 });
expect(output).toEqual([
'rush build: SUCCESS 1/1 operations (1 success) in 15.0s · ' +
'queued behind another request (position 2 at 0.1s)\n'
]);
});
it('leaves the queue to the message of a request that was not admitted', () => {
const { renderer, output } = createRenderer(false);
renderer.onQueuePosition(1);
renderer.finish({ exitCode: 1, admissionErrorCode: 'no-wait', errorMessage: 'The workspace is busy.' });
expect(output).toEqual([
'rush build: FAILURE in 0.0s · daemon admission failed (no-wait): The workspace is busy.\n'
]);
});
it('gives no old queue position as the reason for a failure, but keeps it for a cancellation', () => {
const failed: ITestRenderer = createRenderer(false, 'install');
failed.clock.ms = 200;
failed.renderer.onQueuePosition(1);
failed.clock.ms = 21_600;
failed.renderer.finish({ exitCode: 1 });
expect(failed.lines()).toEqual(['rush install: FAILURE in 21.6s']);
const withMessage: ITestRenderer = createRenderer(false, 'install');
withMessage.renderer.onQueuePosition(1);
withMessage.renderer.finish({ exitCode: 1, errorMessage: 'The mutation failed.' });
expect(withMessage.lines()).toEqual(['rush install: FAILURE in 0.0s · The mutation failed.']);
const cancelled: ITestRenderer = createRenderer(false);
cancelled.clock.ms = 200;
cancelled.renderer.onQueuePosition(1);
cancelled.clock.ms = 3_000;
cancelled.renderer.finish({ exitCode: 130, cancelled: true });
expect(cancelled.lines()).toEqual([
'rush build: CANCELLED in 3.0s · queued behind another request (position 1 at 0.2s)'
]);
});
it('shows the excerpt of a failed operation that reported errors on stdout', () => {
const { renderer, output } = createRenderer(false);
renderer.onEvent(status('ok (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('ok noise\n'), 'ok (build)', 'stdout');
renderer.onEvent(status('ok (build)', 'SUCCESS'));
renderer.onEvent(status('tsc (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('src/x.ts(1,1): error TS1005: stdout-error\n'), 'tsc (build)', 'stdout');
renderer.onEvent(status('tsc (build)', 'FAILURE'));
renderer.finish({ exitCode: 1 });
const text: string = output.join('');
expect(text).toContain('failed: tsc (build)\n src/x.ts(1,1): error TS1005: stdout-error\n');
expect(text).not.toContain('ok noise');
});
it('says so when a failed operation wrote no output', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(status('quiet (build)', 'FAILURE'));
renderer.finish({ exitCode: 1 });
expect(lines().slice(-3)).toEqual([
'failed: quiet (build)',
' (no output)',
'rush build: FAILURE 1/1 operations (1 failure) in 0.0s · failed: quiet (build)'
]);
});
it('shows the queue position immediately on a TTY', () => {
const { renderer, output } = createRenderer(true, 'build', 120);
renderer.onQueuePosition(2);
expect(output[0]).toContain('queued behind another request (position 2)');
renderer.dispose();
});
describe('while the request waits only for operations that an earlier failed command left running', () => {
const TWO: IDaemonContinuingOperations = { count: 2, names: ['t8-slow1', 't8-slow2'] };
const LEFT: string = 'left running by an earlier failed command';
function getPhase(...positions: [number, IDaemonContinuingOperations?][]): string | undefined {
const { renderer, output } = createRenderer(true, 'build', 200);
for (const [position, continuing] of positions) renderer.onQueuePosition(position, continuing);
renderer.dispose();
return / · (queued behind [^\n]*)\n/.exec(
output.filter((text) => text.includes('queued')).pop() ?? ''
)?.[1];
}
it('names them in the phase on a TTY: in the singular, up to three names, and then how many more', () => {
expect(getPhase([1, TWO])).toBe(`queued behind 2 operations ${LEFT} (position 1): t8-slow1, t8-slow2`);
expect(getPhase([1, { count: 1, names: ['t8-slow1'] }])).toBe(
`queued behind 1 operation ${LEFT} (position 1): t8-slow1`
);
expect(getPhase([2, { count: 3, names: ['a', 'b', 'c'] }])).toBe(
`queued behind 3 operations ${LEFT} (position 2): a, b, c`
);
// The daemon names the first three, and the count says how many it did not name.
expect(getPhase([1, { count: 7, names: ['a', 'b', 'c'] }])).toBe(
`queued behind 7 operations ${LEFT} (position 1): a, b, c +4 more`
);
expect(getPhase([1, { count: 5, names: ['a', 'b', 'c', 'd'] }])).toBe(
`queued behind 5 operations ${LEFT} (position 1): a, b, c +2 more`
);
expect(getPhase([1, { count: 2, names: [] }])).toBe(`queued behind 2 operations ${LEFT} (position 1)`);
// A position that names none is a wait for another request, as before.
expect(getPhase([1, TWO], [1])).toBe('queued behind another request (position 1)');
// Each position the daemon sends again names the operations that still run.
expect(getPhase([1, TWO], [1, { count: 1, names: ['t8-slow2'] }])).toBe(
`queued behind 1 operation ${LEFT} (position 1): t8-slow2`
);
});
it('ends the summary line with the first position that named them, not an earlier or a later one', () => {
const { renderer, clock, lines } = createRenderer(false);
clock.ms = 50;
renderer.onQueuePosition(2);
clock.ms = 100;
renderer.onQueuePosition(1, TWO);
clock.ms = 5000;
renderer.onQueuePosition(1, { count: 1, names: ['t8-slow2'] });
clock.ms = 9000;
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.finish({ exitCode: 0 });
expect(lines()).toEqual([
'rush build: SUCCESS 1/1 operations (1 success) in 9.0s · ' +
`queued behind 2 operations ${LEFT} (position 1 at 0.1s): t8-slow1, t8-slow2`
]);
// A request that the daemon never told of them keeps the text it had before.
const other: ITestRenderer = createRenderer(false);
other.clock.ms = 50;
other.renderer.onQueuePosition(2);
other.clock.ms = 9000;
other.renderer.finish({ exitCode: 0 });
expect(other.lines()).toEqual([
'rush build: SUCCESS up to date (no operations needed) in 9.0s · ' +
'queued behind another request (position 2 at 0.1s)'
]);
// As for any queue position, a failure gives its own reason instead.
const failed: ITestRenderer = createRenderer(false);
failed.renderer.onQueuePosition(1, TWO);
failed.renderer.finish({ exitCode: 1 });
expect(failed.lines()).toEqual(['rush build: FAILURE in 0.0s']);
});
it('says that rushd stops them for the request, in the phase and in the summary line', () => {
const STOPPING: IDaemonContinuingOperations = { ...TWO, stopping: true };
const { renderer, output } = createRenderer(true, 'build', 200);
renderer.onQueuePosition(1, STOPPING);
renderer.dispose();
expect(
/ · (stopping [^\n]*)\n/.exec(output.filter((text) => text.includes('stopping')).pop() ?? '')?.[1]
).toBe(`stopping 2 operations ${LEFT} (position 1): t8-slow1, t8-slow2`);
const succeeded: ITestRenderer = createRenderer(false);
succeeded.clock.ms = 100;
succeeded.renderer.onQueuePosition(1, STOPPING);
succeeded.clock.ms = 9000;
succeeded.renderer.finish({ exitCode: 0 });
expect(succeeded.lines()).toEqual([
'rush build: SUCCESS up to date (no operations needed) in 9.0s · ' +
`stopped 2 operations ${LEFT} (position 1 at 0.1s): t8-slow1, t8-slow2`
]);
const cancelled: ITestRenderer = createRenderer(false);
cancelled.clock.ms = 100;
cancelled.renderer.onQueuePosition(1, STOPPING);
cancelled.clock.ms = 3000;
cancelled.renderer.finish({ exitCode: 130, cancelled: true });
expect(cancelled.lines()).toEqual([
`rush build: CANCELLED in 3.0s · stopped 2 operations ${LEFT} (position 1 at 0.1s): t8-slow1, t8-slow2`
]);
// As for any queue position, a failure gives its own reason instead.
const failed: ITestRenderer = createRenderer(false);
failed.renderer.onQueuePosition(1, STOPPING);
failed.renderer.finish({ exitCode: 1 });
expect(failed.lines()).toEqual(['rush build: FAILURE in 0.0s']);
});
});
it('writes a final summary line after a queued request completes', () => {
const { renderer, output, clock } = createRenderer(false);
renderer.start();
renderer.onQueuePosition(1);
clock.ms = 4000;
renderer.finish({ exitCode: 0 });
expect(output[output.length - 1]).toBe(
'rush build: SUCCESS up to date (no operations needed) in 4.0s · ' +
'queued behind another request (position 1 at 0.0s)\n'
);
});
it('writes one progress line and one summary line on a pipe for a large monorepo', () => {
const { renderer, clock, lines } = createRenderer(false);
renderer.start();
renderer.onRequestSent();
renderer.onQueuePosition(1);
const operationIds: string[] = Array.from({ length: 772 }, (unused, i) => `p${i} (build)`);
for (const operationId of operationIds) {
renderer.onEvent(registered(operationId));
}
for (let i: number = 0; i < 1200; i++) {
renderer.onEvent(registered(`p${i} (tool-build)`, true));
}
for (const [index, operationId] of operationIds.entries()) {
clock.ms = index * 270;
renderer.onEvent(status(operationId, 'EXECUTING'));
renderer.onLog(Buffer.from(`building ${operationId}\n`), operationId, 'stdout');
renderer.onEvent(status(operationId, index % 2 ? 'FROM CACHE' : 'SUCCESS'));
renderer.onEvent(header(operationId, index + 1, 772));
renderer.onEvent(event('activityChanged', { text: `${index + 1} of 772 operations complete` }));
}
for (let i: number = 0; i < 1200; i++) {
renderer.onEvent(status(`p${i} (tool-build)`, 'NO OP'));
}
clock.ms = 210_000;
renderer.finish({ exitCode: 0 });
expect(lines()).toEqual([
'rush build · 0.0s · sent to rushd; preparing the workspace graph (status at least every 25s)',
'rush build: SUCCESS 772/772 operations (386 success, 386 from cache) in 210.0s · ' +
'queued behind another request (position 1 at 0.0s)'
]);
});
it('keeps a failure in a large monorepo to the sent line, the failure report and one summary line', () => {
const { renderer, lines } = createRenderer(false);
renderer.start();
renderer.onRequestSent();
for (let i: number = 0; i < 772; i++) {
renderer.onEvent(registered(`p${i} (build)`));
}
for (let i: number = 0; i < 700; i++) {
renderer.onEvent(status(`p${i} (build)`, 'EXECUTING'));
renderer.onLog(Buffer.from(`${'noise '.repeat(20)}\n`.repeat(50)), `p${i} (build)`, 'stdout');
renderer.onEvent(status(`p${i} (build)`, 'SUCCESS'));
}
fail(renderer, 'p700 (build)', [
'src/x.ts:1:1 - error TS2304: Cannot find name "y".',
'Encountered 1 error'
]);
for (let i: number = 701; i < 772; i++) {
renderer.onEvent(status(`p${i} (build)`, 'BLOCKED'));
}
renderer.finish({ exitCode: 1 });
expect(lines()).toEqual([
'rush build · 0.0s · sent to rushd; preparing the workspace graph (status at least every 25s)',
'failed: p700 (build) · full log: /repo/p700/rush-logs/x.log',
' src/x.ts:1:1 - error TS2304: Cannot find name "y".',
'rush build: FAILURE 772/772 operations (1 failure, 71 blocked, 700 success) in 0.0s · failed: p700 (build)'
]);
});
it('ignores silent operations in the counters unless they fail', () => {
const { renderer, output } = createRenderer(false);
renderer.onEvent(registered('a (build)'));
renderer.onEvent(registered('s1 (tool-build)', true));
renderer.onEvent(registered('s2 (tool-build)', true));
renderer.onLog(Buffer.from('silent output\n'), 's1 (tool-build)', 'stderr');
renderer.onEvent(status('s1 (tool-build)', 'NO OP'));
renderer.onEvent(status('s2 (tool-build)', 'FAILURE'));
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.finish({ exitCode: 1 });
const text: string = output.join('');
expect(text).not.toContain('silent output');
expect(output[output.length - 1]).toMatch(
/rush build: FAILURE 2\/2 operations \(1 failure, 1 success\) in 0\.0s · failed: s2 \(tool-build\)\n$/
);
});
it('uses the per-request total from the operation header', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(header('a (build)', 1, 772));
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.finish({ exitCode: 0 });
expect(lines()).toEqual(['rush build: SUCCESS 1/772 operations (1 success) in 0.0s']);
});
it('counts an operation that runs again once', () => {
const { renderer, output } = createRenderer(false);
renderer.onEvent(registered('a (build)'));
renderer.onEvent(status('a (build)', 'FAILURE'));
renderer.onEvent(status('a (build)', 'READY'));
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.finish({ exitCode: 0 });
expect(output[output.length - 1]).toBe('rush build: SUCCESS 1/1 operations (1 success) in 0.0s\n');
});
it('reports operations with warnings when the warnings failed the request', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(status('w (build)', 'EXECUTING'));
renderer.onLog(
Buffer.from('[build:lint] Warning: src/x.ts:1:1 - (rule) message\n'),
'w (build)',
'stderr'
);
renderer.onEvent(status('w (build)', 'SUCCESS WITH WARNINGS', '/repo/w/rush-logs/w._phase_build.log'));
renderer.finish({ exitCode: 1 });
expect(lines().slice(-3)).toEqual([
'warnings: w (build) · full log: /repo/w/rush-logs/w._phase_build.log',
' [build:lint] Warning: src/x.ts:1:1 - (rule) message',
'rush build: FAILURE 1/1 operations (1 success with warnings) in 0.0s · warnings: w (build)'
]);
});
it('reports the output that explains warnings given after an operation succeeded, such as a failed cache write', () => {
const { renderer, lines } = createRenderer(false);
const tarLine: string =
'"tar" exited with code 2 while attempting to create the cache entry. ' +
'See "/repo/a/.rush/temp/a.tar.log" for logs from the tar process.';
for (const operationId of ['a (build)', 'b (build)']) {
renderer.onEvent(status(operationId, 'EXECUTING'));
renderer.onLog(Buffer.from(`built ${operationId}\n`), operationId, 'stdout');
renderer.onLog(Buffer.from(`note from ${operationId}\n`), operationId, 'stderr');
renderer.onEvent(status(operationId, 'SUCCESS'));
}
// Rush writes an operation's build cache entry after its status. If that fails, it writes why and then changes
// the status. The operation's output stream closes last.
renderer.onLog(Buffer.from(`${tarLine}\nUnable to set `), 'a (build)', 'stderr');
renderer.onLog(Buffer.from('local cache entry.\n'), 'a (build)', 'stderr');
renderer.onEvent(event('extension', { name: 'rushd.unknown', data: { operationId: 'a (build)' } }));
renderer.onEvent(status('a (build)', 'SUCCESS WITH WARNINGS', '/repo/a/rush-logs/a._phase_build.log'));
renderer.onEvent(streamClosed('a (build)'));
renderer.onLog(Buffer.from('Successfully set cache entry.\n'), 'b (build)', 'stdout');
renderer.onEvent(streamClosed('b (build)'));
renderer.finish({ exitCode: 1 });
expect(lines()).toEqual([
'warnings: a (build) · full log: /repo/a/rush-logs/a._phase_build.log',
` ${tarLine}`,
' Unable to set local cache entry.',
'rush build: FAILURE 2/2 operations (1 success with warnings, 1 success) in 0.0s · warnings: a (build)'
]);
});
it('reports the output that an operation wrote after it succeeded when it then failed', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('compiled\n'), 'a (build)', 'stdout');
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.onLog(Buffer.from('Unable to set local cache entry.\n'), 'a (build)', 'stderr');
renderer.onEvent(status('a (build)', 'SUCCESS WITH WARNINGS'));
// A later hook threw.
renderer.onEvent(status('a (build)', 'FAILURE', '/repo/a/rush-logs/a._phase_build.log'));
renderer.onEvent(streamClosed('a (build)'));
renderer.finish({
exitCode: 1,
operationResults: [{ operationId: 'a (build)', status: 'FAILURE', errorMessage: 'the plugin failed' }]
});
expect(lines()).toEqual([
'failed: a (build) · full log: /repo/a/rush-logs/a._phase_build.log',
' Unable to set local cache entry.',
'error: a (build)',
' the plugin failed',
'rush build: FAILURE 1/1 operations (1 failure) in 0.0s · failed: a (build)'
]);
});
it('discards the output that an operation wrote after it succeeded once its output stream closes', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onEvent(status('a (build)', 'SUCCESS'));
renderer.onLog(Buffer.from('written after the first run\n'), 'a (build)', 'stderr');
renderer.onEvent(streamClosed('a (build)'));
// The operation runs again.
renderer.onEvent(status('a (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('Warning: from the second run\n'), 'a (build)', 'stderr');
renderer.onEvent(status('a (build)', 'SUCCESS WITH WARNINGS', '/repo/a/rush-logs/a._phase_build.log'));
renderer.onEvent(streamClosed('a (build)'));
renderer.finish({ exitCode: 1 });
expect(lines()).toEqual([
'warnings: a (build) · full log: /repo/a/rush-logs/a._phase_build.log',
' Warning: from the second run',
'rush build: FAILURE 1/1 operations (1 success with warnings) in 0.0s · warnings: a (build)'
]);
});
it('does not report warnings when the request succeeded', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(status('w (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('Warning: x\n'), 'w (build)', 'stderr');
renderer.onEvent(status('w (build)', 'SUCCESS WITH WARNINGS'));
renderer.finish({ exitCode: 0 });
expect(lines().slice(-1)).toEqual([
'rush build: SUCCESS 1/1 operations (1 success with warnings) in 0.0s'
]);
expect(lines().join('\n')).not.toContain('Warning: x');
});
it('says when a failed operation ran its incremental command, and that its next run uses the initial one', () => {
const { renderer, lines } = createRenderer(false);
for (const [name, commandKind] of [
['inc', 'incremental'],
['init', 'initial']
]) {
renderer.onEvent(status(`${name} (build)`, 'EXECUTING'));
renderer.onLog(Buffer.from(`${name} error\n`), `${name} (build)`, 'stderr');
renderer.onEvent(status(`${name} (build)`, 'FAILURE', `/repo/${name}/rush-logs/x.log`, commandKind));
}
renderer.finish({ exitCode: 1 });
expect(lines()).toEqual([
'failed: inc (build) · incremental command; its next run uses the initial command · ' +
'full log: /repo/inc/rush-logs/x.log',
' inc error',
'failed: init (build) · full log: /repo/init/rush-logs/x.log',
' init error',
'rush build: FAILURE 2/2 operations (2 failures) in 0.0s · failed: inc (build), init (build)'
]);
});
it('says when warnings that failed the request came from an incremental command', () => {
const { renderer, lines } = createRenderer(false);
renderer.onEvent(status('w (build)', 'EXECUTING'));
renderer.onLog(Buffer.from('Warning: x\n'), 'w (build)', 'stderr');
renderer.onEvent(status('w (build)', 'SUCCESS WITH WARNINGS', '/repo/w/rush-logs/x.log', 'incremental'));
renderer.finish({ exitCode: 1 });
expect(lines().slice(-3)).toEqual([
'warnings: w (build) · incremental command · full log: /repo/w/rush-logs/x.log',
' Warning: x',
'rush build: FAILURE 1/1 operations (1 success with warnings) in 0.0s · warnings: w (build)'
]);
});
it('names the command of the last run of an operation, and ignores a command it does not know', () => {
const { renderer, lines } = createRenderer(false);
// Operations without output are reported with the summary, after their last run.
renderer.onEvent(status('again (build)', 'FAILURE', undefined, 'incremental'));
renderer.onEvent(status('again (build)', 'READY'));
renderer.onEvent(status('again (build)', 'EXECUTING'));
renderer.onEvent(status('again (build)', 'FAILURE'));
renderer.onEvent(status('odd (build)', 'FAILURE', undefined, 'other'));
renderer.onEvent(status('late (build)', 'FAILURE', undefined, 'initial'));
renderer.onEvent(status('late (build)', 'READY'));
renderer.onEvent(status('late (build)', 'FAILURE', undefined, 'incremental'));
renderer.finish({ exitCode: 1 });
expect(lines().filter((line) => line.startsWith('failed: '))).toEqual([
'failed: again (build)',
'failed: odd (build)',
'failed: late (build) · incremental command; its next run uses the initial command'
]);
});
it('caps the reported operations, their excerpts and the names in the summary', () => {
const { renderer, lines } = createRenderer(false);
for (let i: number = 0; i < 8; i++) {
fail(
renderer,
`f${i} (build)`,
Array.from({ length: 12 }, (unused, j) => `f${i} error ${j}`)
);
}
renderer.finish({ exitCode: 1 });
const report: string[] = lines();
expect(report.filter((line) => line.startsWith('failed: '))).toEqual([
'failed: f0 (build) · full log: /repo/f0/rush-logs/x.log',
'failed: f1 (build) · full log: /repo/f1/rush-logs/x.log',
'failed: f2 (build) · full log: /repo/f2/rush-logs/x.log'
]);
expect(report.filter((line) => line.startsWith(' f0 '))).toHaveLength(8);
expect(report.filter((line) => line.startsWith(' f1 '))).toHaveLength(3);
expect(report.filter((line) => line.startsWith(' f2 '))).toHaveLength(3);
expect(report.slice(-2)).toEqual([
"+5 more failed operations; their logs are in each project's rush-logs folder",
'rush build: FAILURE 8/8 operations (8 failures) in 0.0s · failed: f0 (build), f1 (build), f2 (build), ' +
'f3 (build), f4 (build) +3 more'
]);
});
it('reports a failed operation that wrote no output with the error from the daemon result', () => {
const { renderer, lines } = createRenderer(false);
fail(renderer, 'a (build)', ['src/a.ts:1:1 - error TS2322: a']);
renderer.onEvent(status('quiet (build)', 'FAILURE'));