@@ -11,12 +11,13 @@ import type {
11
11
import axios from "axios" ;
12
12
import * as fs from "fs/promises" ;
13
13
import type { Writable } from "stream" ;
14
- import { coderdPProfPort } from "./constants" ;
14
+ import { coderdPProfPort , enterpriseLicense } from "./constants" ;
15
15
16
16
class CoderReporter implements Reporter {
17
17
config : FullConfig | null = null ;
18
18
testOutput = new Map < string , Array < [ Writable , string ] > > ( ) ;
19
19
passedCount = 0 ;
20
+ skippedCount = 0 ;
20
21
failedTests : TestCase [ ] = [ ] ;
21
22
timedOutTests : TestCase [ ] = [ ] ;
22
23
@@ -31,45 +32,56 @@ class CoderReporter implements Reporter {
31
32
}
32
33
33
34
onStdOut ( chunk : string , test ?: TestCase , _ ?: TestResult ) : void {
34
- for ( const line of filteredServerLogLines ( chunk ) ) {
35
- console . log ( `[stdout] ${ line } ` ) ;
36
- }
35
+ // If there's no associated test, just print it now
37
36
if ( ! test ) {
37
+ for ( const line of logLines ( chunk ) ) {
38
+ console . log ( `[stdout] ${ line } ` ) ;
39
+ }
38
40
return ;
39
41
}
42
+ // Will be printed if the test fails
40
43
this . testOutput . get ( test . id ) ! . push ( [ process . stdout , chunk ] ) ;
41
44
}
42
45
43
46
onStdErr ( chunk : string , test ?: TestCase , _ ?: TestResult ) : void {
44
- for ( const line of filteredServerLogLines ( chunk ) ) {
45
- console . error ( `[stderr] ${ line } ` ) ;
46
- }
47
+ // If there's no associated test, just print it now
47
48
if ( ! test ) {
49
+ for ( const line of logLines ( chunk ) ) {
50
+ console . error ( `[stderr] ${ line } ` ) ;
51
+ }
48
52
return ;
49
53
}
54
+ // Will be printed if the test fails
50
55
this . testOutput . get ( test . id ) ! . push ( [ process . stderr , chunk ] ) ;
51
56
}
52
57
53
58
async onTestEnd ( test : TestCase , result : TestResult ) {
54
- console . log ( `==> Finished test ${ test . title } : ${ result . status } ` ) ;
59
+ try {
60
+ if ( test . expectedStatus === "skipped" ) {
61
+ console . log ( `==> Skipping test ${ test . title } ` ) ;
62
+ this . skippedCount ++ ;
63
+ return ;
64
+ }
55
65
56
- if ( result . status === "passed" ) {
57
- this . passedCount ++ ;
58
- }
66
+ console . log ( `==> Finished test ${ test . title } : ${ result . status } ` ) ;
59
67
60
- if ( result . status === "failed" ) {
61
- this . failedTests . push ( test ) ;
62
- }
68
+ if ( result . status === "passed" ) {
69
+ this . passedCount ++ ;
70
+ return ;
71
+ }
63
72
64
- if ( result . status === "timedOut" ) {
65
- this . timedOutTests . push ( test ) ;
66
- }
73
+ if ( result . status === "failed" ) {
74
+ this . failedTests . push ( test ) ;
75
+ }
76
+
77
+ if ( result . status === "timedOut" ) {
78
+ this . timedOutTests . push ( test ) ;
79
+ }
67
80
68
- const fsTestTitle = test . title . replaceAll ( " " , "-" ) ;
69
- const outputFile = `test-results/debug-pprof-goroutine-${ fsTestTitle } .txt` ;
70
- await exportDebugPprof ( outputFile ) ;
81
+ const fsTestTitle = test . title . replaceAll ( " " , "-" ) ;
82
+ const outputFile = `test-results/debug-pprof-goroutine-${ fsTestTitle } .txt` ;
83
+ await exportDebugPprof ( outputFile ) ;
71
84
72
- if ( result . status !== "passed" ) {
73
85
console . log ( `Data from pprof has been saved to ${ outputFile } ` ) ;
74
86
console . log ( "==> Output" ) ;
75
87
const output = this . testOutput . get ( test . id ) ! ;
@@ -90,13 +102,22 @@ class CoderReporter implements Reporter {
90
102
console . log ( attachment ) ;
91
103
}
92
104
}
105
+ } finally {
106
+ this . testOutput . delete ( test . id ) ;
93
107
}
94
- this . testOutput . delete ( test . id ) ;
95
108
}
96
109
97
110
onEnd ( result : FullResult ) {
98
111
console . log ( `==> Tests ${ result . status } ` ) ;
112
+ if ( ! enterpriseLicense ) {
113
+ console . log (
114
+ "==> Enterprise tests were skipped, because no license was provided" ,
115
+ ) ;
116
+ }
99
117
console . log ( `${ this . passedCount } passed` ) ;
118
+ if ( this . skippedCount > 0 ) {
119
+ console . log ( `${ this . skippedCount } skipped` ) ;
120
+ }
100
121
if ( this . failedTests . length > 0 ) {
101
122
console . log ( `${ this . failedTests . length } failed` ) ;
102
123
for ( const test of this . failedTests ) {
@@ -112,11 +133,7 @@ class CoderReporter implements Reporter {
112
133
}
113
134
}
114
135
115
- const shouldPrintLine = ( line : string ) =>
116
- [ " error=EOF" , "coderd: audit_log" ] . every ( ( noise ) => ! line . includes ( noise ) ) ;
117
-
118
- const filteredServerLogLines = ( chunk : string ) : string [ ] =>
119
- chunk . trimEnd ( ) . split ( "\n" ) . filter ( shouldPrintLine ) ;
136
+ const logLines = ( chunk : string ) : string [ ] => chunk . trimEnd ( ) . split ( "\n" ) ;
120
137
121
138
const exportDebugPprof = async ( outputFile : string ) => {
122
139
const response = await axios . get (
0 commit comments