File tree Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 4
4
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
*/
6
6
7
- use crate :: util:: bail;
7
+ use crate :: util:: { bail, KvParser } ;
8
+ use crate :: ParseResult ;
8
9
use proc_macro2:: TokenStream ;
9
10
use quote:: quote;
10
- use venial:: { Declaration , Error } ;
11
+ use venial:: Declaration ;
11
12
12
- pub fn transform ( input_decl : Declaration ) -> Result < TokenStream , Error > {
13
+ pub fn transform ( input_decl : Declaration ) -> ParseResult < TokenStream > {
13
14
let func = match input_decl {
14
15
Declaration :: Function ( f) => f,
15
16
_ => return bail ( "#[itest] can only be applied to functions" , & input_decl) ,
@@ -27,10 +28,21 @@ pub fn transform(input_decl: Declaration) -> Result<TokenStream, Error> {
27
28
) ;
28
29
}
29
30
31
+ let mut attr = KvParser :: parse_required ( & func. attributes , "itest" , & func. name ) ?;
32
+ let skipped = attr. handle_alone ( "skip" ) ?;
33
+ let focused = attr. handle_alone ( "focus" ) ?;
34
+ attr. finish ( ) ?;
35
+
36
+ if skipped && focused {
37
+ return bail (
38
+ "#[itest]: keys `skip` and `focus` are mutually exclusive" ,
39
+ func. name ,
40
+ ) ;
41
+ }
42
+
30
43
let test_name = & func. name ;
31
44
let test_name_str = func. name . to_string ( ) ;
32
45
let body = & func. body ;
33
- let skipped = false ;
34
46
35
47
Ok ( quote ! {
36
48
pub fn #test_name( ) {
Original file line number Diff line number Diff line change @@ -170,9 +170,10 @@ impl KvParser {
170
170
// Useless allocation, but there seems to be no join() on map iterators. Anyway, this is slow/error path.
171
171
let keys = self . map . keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
172
172
173
+ let s = if self . map . len ( ) > 1 { "s" } else { "" } ; // plural
173
174
return bail (
174
175
format ! (
175
- "#[{attr}]: unrecognized keys : {keys}" ,
176
+ "#[{attr}]: unrecognized key{s} : {keys}" ,
176
177
attr = self . attr_name
177
178
) ,
178
179
self . span ,
Original file line number Diff line number Diff line change @@ -94,7 +94,13 @@ impl IntegrationTests {
94
94
let gdscript_time = gdscript_time. as_secs_f32 ( ) ;
95
95
let total_time = rust_time + gdscript_time;
96
96
97
- println ! ( "\n Test result: {outcome}. {passed} passed; {failed} failed." ) ;
97
+ let extra = if skipped > 0 {
98
+ format ! ( ", {skipped} skipped" )
99
+ } else {
100
+ "" . to_string ( )
101
+ } ;
102
+
103
+ println ! ( "\n Test result: {outcome}. {passed} passed; {failed} failed{extra}." ) ;
98
104
println ! ( " Time: {total_time:.2}s. (Rust {rust_time:.2}s, GDScript {gdscript_time:.2}s)" ) ;
99
105
all_passed
100
106
}
@@ -191,7 +197,7 @@ impl std::fmt::Display for TestOutcome {
191
197
let ( col, outcome) = match self {
192
198
TestOutcome :: Passed => ( FMT_GREEN , "ok" ) ,
193
199
TestOutcome :: Failed => ( FMT_RED , "FAILED" ) ,
194
- TestOutcome :: Skipped => ( FMT_YELLOW , "ignored " ) ,
200
+ TestOutcome :: Skipped => ( FMT_YELLOW , "skipped " ) ,
195
201
} ;
196
202
197
203
write ! ( f, "{col}{outcome}{end}" )
You can’t perform that action at this time.
0 commit comments