@@ -20,69 +20,6 @@ const path = require('path');
2020const { spawn } = require ( 'child-process-promise' ) ;
2121const { writeFileSync } = require ( 'fs' ) ;
2222
23- /**
24- * Creates and returns a "timestamp" string for the elapsed time.
25- *
26- * The given timestamp is taken as an offset from the first time that this
27- * function is invoked. This allows log messages to start at "time 0" and make
28- * it easy for humans to calculate the elapsed time.
29- *
30- * @returns The timestamp string with which to prefix log lines, created from
31- * the elapsed time since this function's first invocation.
32- */
33- function elapsedTimeStr ( ) {
34- const milliseconds = getElapsedMilliseconds ( ) ;
35- const minutes = Math . floor ( milliseconds / ( 1000 * 60 ) ) ;
36- const seconds = ( milliseconds - minutes * 1000 * 60 ) / 1000 ;
37- return (
38- ( minutes < 10 ? '0' : '' ) +
39- minutes +
40- ':' +
41- ( seconds < 10 ? '0' : '' ) +
42- seconds . toFixed ( 3 )
43- ) ;
44- }
45-
46- /**
47- * The "start time", which is set to a non-null value upon the first invocation
48- * of `getElapsedMilliseconds()`. All subsequent invocations calculate the
49- * elapsed time using this value.
50- */
51- let elapsedMillisecondsStartTime = null ;
52-
53- /**
54- * Returns the number of nanoseconds that have elapsed since this function's
55- * first invocation. Returns 0 on its first invocation.
56- */
57- function getElapsedMilliseconds ( ) {
58- const currentTimeMilliseconds = getCurrentMonotonicTimeMilliseconds ( ) ;
59- if ( elapsedMillisecondsStartTime === null ) {
60- elapsedMillisecondsStartTime = currentTimeMilliseconds ;
61- return 0 ;
62- }
63- return currentTimeMilliseconds - elapsedMillisecondsStartTime ;
64- }
65-
66- /**
67- * Returns the current time, in milliseconds, from a monotonic clock.
68- */
69- function getCurrentMonotonicTimeMilliseconds ( ) {
70- const currentTime = process . hrtime ( ) ;
71- return currentTime [ 0 ] * 1000 + currentTime [ 1 ] / 1_000_000 ;
72- }
73-
74- function debugLog ( ...args ) {
75- // eslint-disable-next-line no-console
76- console . log ( __filename , elapsedTimeStr ( ) , ...args ) ;
77- }
78-
79- function errorLog ( ...args ) {
80- // eslint-disable-next-line no-console
81- console . error ( __filename , elapsedTimeStr ( ) , ...args ) ;
82- }
83-
84- debugLog ( `command-line arguments: ${ process . argv . join ( ' ' ) } ` ) ;
85-
8623const LOGDIR = process . env . CI ? process . env . HOME : '/tmp' ;
8724// Maps the packages where we should not run `test:all` and instead isolate the cross-browser tests.
8825// TODO(dwyfrequency): Update object with `storage` and `firestore` packages.
@@ -132,10 +69,7 @@ const argv = yargs.options({
13269 }
13370 }
13471 }
135-
136- const yarnArgs = [ '--cwd' , dir , scriptName ] ;
137- debugLog ( `spawning '${ name } ' process: yarn ${ yarnArgs . join ( ' ' ) } ` ) ;
138- const testProcess = spawn ( 'yarn' , yarnArgs ) ;
72+ const testProcess = spawn ( 'yarn' , [ '--cwd' , dir , scriptName ] ) ;
13973
14074 testProcess . childProcess . stdout . on ( 'data' , data => {
14175 stdout += data . toString ( ) ;
@@ -145,20 +79,13 @@ const argv = yargs.options({
14579 } ) ;
14680
14781 await testProcess ;
148- debugLog (
149- `'${ name } ' process completed successfully: yarn ${ yarnArgs . join ( ' ' ) } `
150- ) ;
82+ console . log ( 'Success: ' + name ) ;
15183 writeLogs ( 'Success' , name , stdout + '\n' + stderr ) ;
15284 } catch ( e ) {
153- errorLog ( `${ name } process FAILED` ) ;
154- errorLog ( `${ name } process ==== STDOUT BEGIN ====` ) ;
85+ console . error ( 'Failure: ' + name ) ;
15586 console . log ( stdout ) ;
156- errorLog ( `${ name } process ==== STDOUT END ====` ) ;
157- errorLog ( `${ name } process ==== STDERR BEGIN ====` ) ;
15887 console . error ( stderr ) ;
159- errorLog ( `${ name } process ==== STDERR END ====` ) ;
16088 writeLogs ( 'Failure' , name , stdout + '\n' + stderr ) ;
161- errorLog ( 'Completing with failure exit code 76' ) ;
162- process . exit ( 76 ) ;
89+ process . exit ( 1 ) ;
16390 }
16491} ) ( ) ;
0 commit comments