@@ -30,27 +30,33 @@ export class TestsParser implements ITestsParser {
30
30
31
31
let haveErrors = false ;
32
32
33
- let packagePrefix : string = '' ;
33
+ const packages : { indent : number ; packagePrefix : string } [ ] = [ ] ;
34
34
content . split ( / \r ? \n / g) . forEach ( ( line , index , lines ) => {
35
35
if ( options . token && options . token . isCancellationRequested ) {
36
36
return ;
37
37
}
38
38
39
39
const trimmedLine : string = line . trim ( ) ;
40
40
41
- if ( trimmedLine . startsWith ( '<Package \'' ) ) {
41
+ if ( trimmedLine . startsWith ( '<Package \'' ) || trimmedLine . startsWith ( '<Module \'' ) || index === lines . length - 1 ) {
42
+ let packagePrefix : string = '' ;
43
+ if ( packages . length > 0 ) {
44
+ packagePrefix = packages [ packages . length - 1 ] . packagePrefix ;
45
+ }
42
46
// Process the previous lines.
43
47
this . parsePyTestModuleCollectionResult ( options . cwd , logOutputLines , testFiles , parentNodes , packagePrefix ) ;
48
+ let indent = line . indexOf ( '<' ) ;
49
+ while ( packages . length > 0 && packages [ packages . length - 1 ] . indent >= indent ) {
50
+ packages . pop ( ) ;
51
+ }
44
52
logOutputLines = [ '' ] ;
45
-
46
- packagePrefix = this . extractPackageName ( trimmedLine , options . cwd ) ;
53
+ if ( trimmedLine . startsWith ( '<Package \'' ) ) {
54
+ indent = line . indexOf ( '<' ) ;
55
+ packagePrefix = this . extractPackageName ( trimmedLine , options . cwd ) ;
56
+ packages . push ( { indent : indent , packagePrefix : packagePrefix } ) ;
57
+ }
47
58
}
48
59
49
- if ( trimmedLine . startsWith ( '<Module \'' ) || index === lines . length - 1 ) {
50
- // Process the previous lines.
51
- this . parsePyTestModuleCollectionResult ( options . cwd , logOutputLines , testFiles , parentNodes , packagePrefix ) ;
52
- logOutputLines = [ '' ] ;
53
- }
54
60
if ( errorLine . test ( line ) ) {
55
61
haveErrors = true ;
56
62
logOutputLines = [ '' ] ;
0 commit comments