@@ -4,87 +4,50 @@ import yaml from 'yaml';
44
55import { shortenTestFileLabels } from './util.js' ;
66
7- function dynamic ( eventbus ) {
8- /**
9- * @typedef {Object } ClientState
10- * @property {string } clientId
11- * @property {string } displayName
12- * @property {string } status
13- * @property {null|string } lastline
14- */
15-
16- /** @type {Object<string,ClientState[]> } */
17- const clientsByFile = Object . create ( null ) ;
18- /** @type {Object<string,ClientState> } */
19- const clientsById = Object . create ( null ) ;
20-
21- let screen = '' ;
22-
23- function render ( ) {
24- const icons = { waiting : '⢎' , progress : '⠧' , success : '✔' , failure : '✘' } ;
25- let str = '' ;
26- for ( const testFile in clientsByFile ) {
27- str += `\nRunning ${ testFile } \n` ;
28- for ( const client of clientsByFile [ testFile ] ) {
29- str += `* ${ client . displayName } ${ icons [ client . status ] } ${ client . lastline || '' } \n` ;
30- }
31- }
32-
33- if ( screen ) {
34- const oldHeight = screen . split ( '\n' ) . length ;
35- for ( let i = 1 ; i < oldHeight ; i ++ ) {
36- process . stdout . write ( '\x1b[A\x1b[K' ) ;
37- }
38- }
39-
40- process . stdout . write ( str ) ;
41- screen = str ;
42- }
43-
44- eventbus . on ( 'client' , ( event ) => {
45- const client = {
46- clientId : event . clientId ,
47- displayName : event . displayName ,
48- status : 'waiting' ,
49- lastline : null
50- } ;
51-
52- clientsByFile [ event . testFile ] ??= [ ] ;
53- clientsByFile [ event . testFile ] . push ( client ) ;
54- clientsById [ event . clientId ] = client ;
55- render ( ) ;
56- } ) ;
57-
58- eventbus . on ( 'clientonline' , ( event ) => {
59- clientsById [ event . clientId ] . status = 'progress' ;
60- render ( ) ;
61- } ) ;
62-
63- eventbus . on ( 'clientresult' , ( event ) => {
64- clientsById [ event . clientId ] . status = event . ok ? 'success' : 'failure' ;
65- render ( ) ;
66- } ) ;
67-
68- /*
69- const browserCount = (clients.size / testFiles.size);
70- let onlineMsg;
71- if (testFiles.size === 1 && browserCount === 1) {
72- onlineMsg = util.styleText('grey', `Running tests in ${client.browser}`);
73- } else if (testFiles.size === 1) {
74- onlineMsg = util.styleText('grey', `Running tests in ${browserCount} browsers`);
75- } else if (browserCount === 1) {
76- onlineMsg = util.styleText('grey', `Running ${testFiles.size} test files in ${client.browser}`);
77- } else {
78- onlineMsg = util.styleText('grey', `Running ${testFiles.size} test files in ${browserCount} browsers`);
79- }
80- */
7+ function dynamic ( _eventbus ) {
8+ // const icons = { waiting: '⢎', progress: '⠧', success: '✔', failure: '✘' };
9+ // "interval": 80,
10+ // "frames": [
11+ // "⠋",
12+ // "⠙",
13+ // "⠹",
14+ // "⠸",
15+ // "⠼",
16+ // "⠴",
17+ // "⠦",
18+ // "⠧",
19+ // "⠇",
20+ // "⠏"
21+ // ]
22+ // "frames": [
23+ // "⢎ ",
24+ // "⠎⠁",
25+ // "⠊⠑",
26+ // "⠈⠱",
27+ // " ⡱",
28+ // "⢀⡰",
29+ // "⢄⡠",
30+ // "⢆⡀"
31+ // ]
32+ // let screen = '';
33+ // function render () {
34+ // let str = '';
35+ // if (screen) {
36+ // const oldHeight = screen.split('\n').length;
37+ // for (let i = 1; i < oldHeight; i++) {
38+ // process.stdout.write('\x1b[A\x1b[K');
39+ // }
40+ // }
41+ // process.stdout.write(str);
42+ // screen = str;
43+ // }
8144}
8245
8346function plain ( eventbus ) {
8447 const WAIT_MSG_GRACE = 3000 ;
8548 const TEST_MSG_GRACE = 1000 ;
8649
87- const perfOrigin = performance . now ( ) ;
50+ let perfOrigin ;
8851
8952 /**
9053 * @typedef {Object } Client
@@ -196,6 +159,8 @@ function plain (eventbus) {
196159 const client = /** @type {Client } */ ( clients . get ( event . clientId ) ) ;
197160 clearTimeout ( client . waitMsgTimer ) ;
198161
162+ perfOrigin ??= performance . now ( ) ;
163+
199164 let line ;
200165 if ( browserCount === 1 ) {
201166 line = util . styleText ( 'grey' , `${ client . linePrefix } ⠧ Running tests in ${ client . browser } ` ) ;
@@ -367,51 +332,36 @@ export default { none, minimal };
367332
368333 ===============================================================
369334
370- Running / test/timeout .html
371- * Firefox ⠧ ok 2 Baz > this thing
372- * Chrome ⠧ ok 1 Foo bar
335+ $ qtap test/fixtures/pass .html
336+ [ Firefox Headless] ⠧ ok 2 Baz > this thing
337+ [ Chrome Headless ] ⠧ ok 1 Foo bar
373338
374339 ===============================================================
375340
376- Running / test/timeout.html
377- * Firefox ✘ Timed out after 30s of inactivity
378- * Chrome ✘ Timed out after 30s of inactivity
341+ $ qtap --timeout 3 test/fixtures /timeout.html
342+ [ Firefox Headless] ✘ Test timed out after 30s
343+ [ Chrome Headless ] ✘ Test timed out after 30s
379344
380345 ===============================================================
381346
382347 Running /test/connect-timeout.html
383- * Firefox ⢎ Waiting...
384- * Chrome ⢎ Waiting...
348+ $ bin/qtap.js -c test/fixtures/qtap.config.js -b fakeRefuse test/fixtures/pass.html
349+ [Firefox Headless] ⢎ Waiting for browser to connect...
350+ [Chrome Headless ] ⢎ Waiting for browser to connect...
385351
386352 ===============================================================
387353
388- Running /test/connect-timeout.html
389- * Firefox ✘ Browser did not start within 60s
390- * Chrome ✘ Browser did not start within 60s after 3 retries.
391-
392- # Spinner
393-
394- "interval": 80,
395- "frames": [
396- "⠋",
397- "⠙",
398- "⠹",
399- "⠸",
400- "⠼",
401- "⠴",
402- "⠦",
403- "⠧",
404- "⠇",
405- "⠏"
406- ]
407- "frames": [
408- "⢎ ",
409- "⠎⠁",
410- "⠊⠑",
411- "⠈⠱",
412- " ⡱",
413- "⢀⡰",
414- "⢄⡠",
415- "⢆⡀"
416- ]
354+ $ bin/qtap.js -c test/fixtures/qtap.config.js --connect-timeout 3 -b fakeRefuse test/fixtures/pass.html
355+ ✘ Browser did not start within 6s
356+
357+ $ bin/qtap.js -c test/fixtures/qtap.config.js --connect-timeout 3 -b fakeLazy test/fixtures/fake_pass_4.txt
358+ ⠧ Waiting for browser to connect
359+ ⠧ Running tests in fakeLazy
360+ ✔ Completed 4 tests
361+
362+ ===============================================================
363+
364+ $ qtap -c test/fixtures/qtap.config.js -b fakeRefuseAlways test/fixtures/pass.html
365+ ✘ Browser did not start within 60s after 3 attempts.
366+
417367*/
0 commit comments