@@ -20,7 +20,7 @@ const targetPatternNamedCaptureGroup = {
20
20
21
21
// when target is lib/bin, there is "unittests ", when target is integration test, there is not
22
22
const sepInRegexString = sep === '\\' ? '\\\\' : sep ;
23
- const targetPattern = new RegExp ( `Running (?:unittests )?(?<${ targetPatternNamedCaptureGroup . relativePath } >.*?) \\ (.*${ sepInRegexString } (?<${ targetPatternNamedCaptureGroup . normalizedPackageName } >.*?)-\ \)` ) ;
23
+ const targetPattern = new RegExp ( `Running (?:unittests )?(?<${ targetPatternNamedCaptureGroup . relativePath } >.*?) \(.*${ sepInRegexString } (?<${ targetPatternNamedCaptureGroup . normalizedPackageName } >.*?)-.*? \)` ) ;
24
24
25
25
const caseResultPattern = / ^ t e s t ( .* ?) ... ( \w * ) $ / ;
26
26
const stacktraceTestCasePattern = / ^ - - - - ( .* ?) s t d o u t - - - - $ / ;
@@ -40,11 +40,21 @@ export class RustcOutputAnalyzer {
40
40
}
41
41
42
42
public onStdErr ( data : any ) {
43
- // TODO: maybe testRun.error() might be helpful?
43
+ // This is so weird, some messages will be logged as stderr
44
+ // like "Finished test [unoptimized + debuginfo] target(s) in 0.07s"
45
+ // and "Running unittests src\lib.rs (target\debug\deps\hashbrown-3547e1bc587fc63a.exe)"
46
+
47
+ // And this make ir hard to use breakpoint to debug, because the buffer will be flushed in unexpected order.
44
48
const normalizedData = normalizeOutputData ( data ) ;
45
- normalizedData . split ( '\r\n' ) ;
46
49
50
+ this . testRun . appendOutput ( normalizedData ) ;
47
51
console . log ( `StdErr:${ data } ` ) ;
52
+
53
+ const lines = normalizedData . split ( "\r\n" ) ;
54
+
55
+ lines . forEach ( line => {
56
+ this . analyticsCurrentTestTarget ( line ) ;
57
+ } ) ;
48
58
}
49
59
50
60
public onClose ( ) {
@@ -60,12 +70,8 @@ export class RustcOutputAnalyzer {
60
70
console . log ( `Stdout:${ data } ` ) ;
61
71
62
72
const lines = normalizedData . split ( "\r\n" ) ;
63
- // At the end of the output, when the tests are all finished
64
- // stack trace(if any failed) will be output together in a big `data`
65
- // set this flag to analytics all the output
66
73
67
74
lines . forEach ( line => {
68
- this . analyticsCurrentTestTarget ( line ) ;
69
75
this . analyticsTestCaseResult ( line ) ;
70
76
this . analyticsStackTrace ( line ) ;
71
77
} ) ;
@@ -75,7 +81,7 @@ export class RustcOutputAnalyzer {
75
81
private _currentTargetRelativePath : string | undefined = undefined ;
76
82
77
83
private analyticsCurrentTestTarget ( line : string ) {
78
- const match = targetPattern . exec ( line ) ;
84
+ const match = targetPattern . exec ( line ) ; // Running unittests src\\lib.rs (target\\debug\\deps\\hashbrown-3547e1bc587fc63a.exe)
79
85
if ( match ) {
80
86
this . _currentNormalizedPackageName = match ?. groups ?. [ targetPatternNamedCaptureGroup . normalizedPackageName ] ;
81
87
this . _currentTargetRelativePath = match ?. groups ?. [ targetPatternNamedCaptureGroup . relativePath ] ;
@@ -112,6 +118,10 @@ export class RustcOutputAnalyzer {
112
118
}
113
119
}
114
120
121
+
122
+ // At the end of the output, when the tests are all finished
123
+ // stack trace(if any failed) will be output together in a big `data`
124
+ // set this flag to analytics all the output
115
125
private _failureContextAnalyticsFlag = false ;
116
126
private _currentFailedRustcOutputTest : vscode . TestItem | undefined = undefined ;
117
127
private _currentFailedCaseOutputWithStackTrace : string [ ] = [ ] ;
@@ -152,7 +162,7 @@ export class RustcOutputAnalyzer {
152
162
153
163
// why replace: refer https://code.visualstudio.com/api/extension-guides/testing#test-output
154
164
function normalizeOutputData ( data : any ) : string {
155
- return data . toString ( ) . replace ( / \n / g, '\r\n' ) ;
165
+ return data . toString ( ) . replace ( / \r \n / g , '\n' ) . replace ( / \ n/ g, '\r\n' ) ;
156
166
}
157
167
158
168
enum RustcTestResult {
0 commit comments