@@ -19,7 +19,7 @@ use boa_engine::{
1919} ;
2020use colored:: Colorize ;
2121use rayon:: prelude:: * ;
22- use rustc_hash:: FxHashSet ;
22+ use rustc_hash:: FxHashMap ;
2323use std:: { cell:: RefCell , eprintln, rc:: Rc } ;
2424
2525impl TestSuite {
@@ -31,12 +31,12 @@ impl TestSuite {
3131 parallel : bool ,
3232 max_edition : SpecEdition ,
3333 optimizer_options : OptimizerOptions ,
34- ) -> SuiteResult {
34+ ) -> ( Box < str > , SuiteResult ) {
3535 if verbose != 0 {
3636 println ! ( "Suite {}:" , self . path. display( ) ) ;
3737 }
3838
39- let suites: Vec < _ > = if parallel {
39+ let suites: FxHashMap < _ , _ > = if parallel {
4040 self . suites
4141 . par_iter ( )
4242 . map ( |suite| suite. run ( harness, verbose, parallel, max_edition, optimizer_options) )
@@ -48,25 +48,20 @@ impl TestSuite {
4848 . collect ( )
4949 } ;
5050
51- let tests: Vec < _ > = if parallel {
51+ let tests: FxHashMap < _ , _ > = if parallel {
5252 self . tests
5353 . par_iter ( )
5454 . filter ( |test| test. edition <= max_edition)
55- . flat_map ( |test| test. run ( harness, verbose, optimizer_options) )
55+ . map ( |test| test. run ( harness, verbose, optimizer_options) )
5656 . collect ( )
5757 } else {
5858 self . tests
5959 . iter ( )
6060 . filter ( |test| test. edition <= max_edition)
61- . flat_map ( |test| test. run ( harness, verbose, optimizer_options) )
61+ . map ( |test| test. run ( harness, verbose, optimizer_options) )
6262 . collect ( )
6363 } ;
6464
65- let mut features = FxHashSet :: default ( ) ;
66- for test_iter in & * self . tests {
67- features. extend ( test_iter. features . iter ( ) . map ( ToString :: to_string) ) ;
68- }
69-
7065 if verbose != 0 {
7166 println ! ( ) ;
7267 }
@@ -75,27 +70,29 @@ impl TestSuite {
7570 let mut versioned_stats = VersionedStats :: default ( ) ;
7671 let mut es_next = Statistics :: default ( ) ;
7772
78- for test in & tests {
79- match test. result {
80- TestOutcomeResult :: Passed => {
73+ for test in tests. values ( ) {
74+ match ( test. strict , test. no_strict ) {
75+ ( Some ( TestOutcomeResult :: Passed ) , None | Some ( TestOutcomeResult :: Passed ) )
76+ | ( None , Some ( TestOutcomeResult :: Passed ) ) => {
8177 versioned_stats. apply ( test. edition , |stats| {
8278 stats. passed += 1 ;
8379 } ) ;
8480 es_next. passed += 1 ;
8581 }
86- TestOutcomeResult :: Ignored => {
82+ ( Some ( TestOutcomeResult :: Ignored ) , _ ) | ( _ , Some ( TestOutcomeResult :: Ignored ) ) => {
8783 versioned_stats. apply ( test. edition , |stats| {
8884 stats. ignored += 1 ;
8985 } ) ;
9086 es_next. ignored += 1 ;
9187 }
92- TestOutcomeResult :: Panic => {
88+ ( Some ( TestOutcomeResult :: Panic ) , _ ) | ( _ , Some ( TestOutcomeResult :: Panic ) ) => {
9389 versioned_stats. apply ( test. edition , |stats| {
9490 stats. panic += 1 ;
9591 } ) ;
9692 es_next. panic += 1 ;
9793 }
98- TestOutcomeResult :: Failed => { }
94+ ( Some ( TestOutcomeResult :: Failed ) , _) | ( _, Some ( TestOutcomeResult :: Failed ) ) => { }
95+ ( None , None ) => unreachable ! ( "test should have at least one result" ) ,
9996 }
10097 versioned_stats. apply ( test. edition , |stats| {
10198 stats. total += 1 ;
@@ -104,10 +101,9 @@ impl TestSuite {
104101 }
105102
106103 // Count total tests
107- for suite in & suites {
104+ for suite in suites. values ( ) {
108105 versioned_stats += suite. versioned_stats ;
109106 es_next += suite. stats ;
110- features. extend ( suite. features . iter ( ) . cloned ( ) ) ;
111107 }
112108
113109 if verbose != 0 {
@@ -128,39 +124,47 @@ impl TestSuite {
128124 ( es_next. passed as f64 / es_next. total as f64 ) * 100.0
129125 ) ;
130126 }
131- SuiteResult {
132- name : self . name . clone ( ) ,
133- stats : es_next,
134- versioned_stats,
135- suites,
136- tests,
137- features,
138- }
127+ (
128+ self . name . clone ( ) ,
129+ SuiteResult {
130+ stats : es_next,
131+ versioned_stats,
132+ suites,
133+ tests,
134+ } ,
135+ )
139136 }
140137}
141138
142139impl Test {
143140 /// Runs the test.
141+ ///
142+ /// Returns the test name and the result of the test.
144143 pub ( crate ) fn run (
145144 & self ,
146145 harness : & Harness ,
147146 verbose : u8 ,
148147 optimizer_options : OptimizerOptions ,
149- ) -> Vec < TestResult > {
150- let mut results = Vec :: new ( ) ;
148+ ) -> ( Box < str > , TestResult ) {
149+ let mut result = TestResult {
150+ edition : self . edition ,
151+ strict : None ,
152+ no_strict : None ,
153+ } ;
154+
151155 if self . flags . contains ( TestFlags :: MODULE ) {
152- results . push ( self . run_once ( harness, false , verbose, optimizer_options) ) ;
156+ result . no_strict = Some ( self . run_once ( harness, false , verbose, optimizer_options) ) ;
153157 } else {
154158 if self . flags . contains ( TestFlags :: STRICT ) && !self . flags . contains ( TestFlags :: RAW ) {
155- results . push ( self . run_once ( harness, true , verbose, optimizer_options) ) ;
159+ result . strict = Some ( self . run_once ( harness, true , verbose, optimizer_options) ) ;
156160 }
157161
158162 if self . flags . contains ( TestFlags :: NO_STRICT ) || self . flags . contains ( TestFlags :: RAW ) {
159- results . push ( self . run_once ( harness, false , verbose, optimizer_options) ) ;
163+ result . no_strict = Some ( self . run_once ( harness, false , verbose, optimizer_options) ) ;
160164 }
161165 }
162166
163- results
167+ ( self . name . clone ( ) , result )
164168 }
165169
166170 /// Runs the test once, in strict or non-strict mode
@@ -170,7 +174,7 @@ impl Test {
170174 strict : bool ,
171175 verbose : u8 ,
172176 optimizer_options : OptimizerOptions ,
173- ) -> TestResult {
177+ ) -> TestOutcomeResult {
174178 let Ok ( source) = Source :: from_filepath ( & self . path ) else {
175179 if verbose > 1 {
176180 println ! (
@@ -182,13 +186,7 @@ impl Test {
182186 } else {
183187 print ! ( "{}" , "F" . red( ) ) ;
184188 }
185- return TestResult {
186- name : self . name . clone ( ) ,
187- edition : self . edition ,
188- strict,
189- result : TestOutcomeResult :: Failed ,
190- result_text : Box :: from ( "Could not read test file." ) ,
191- } ;
189+ return TestOutcomeResult :: Failed ;
192190 } ;
193191 if self . ignored {
194192 if verbose > 1 {
@@ -201,13 +199,7 @@ impl Test {
201199 } else {
202200 print ! ( "{}" , "-" . yellow( ) ) ;
203201 }
204- return TestResult {
205- name : self . name . clone ( ) ,
206- edition : self . edition ,
207- strict,
208- result : TestOutcomeResult :: Ignored ,
209- result_text : Box :: default ( ) ,
210- } ;
202+ return TestOutcomeResult :: Ignored ;
211203 }
212204 if verbose > 1 {
213205 println ! (
@@ -512,13 +504,7 @@ impl Test {
512504 println ! ( ) ;
513505 }
514506
515- TestResult {
516- name : self . name . clone ( ) ,
517- edition : self . edition ,
518- strict,
519- result,
520- result_text : result_text. into_boxed_str ( ) ,
521- }
507+ result
522508 }
523509
524510 /// Sets the environment up to run the test.
0 commit comments