File tree Expand file tree Collapse file tree 1 file changed +11
-24
lines changed
Expand file tree Collapse file tree 1 file changed +11
-24
lines changed Original file line number Diff line number Diff line change 1- // tests8.rs
2- //
3- // This execrise shares `build.rs` with the previous exercise.
4- // You need to add some code to `build.rs` to make both this exercise and
5- // the previous one work.
6- //
7- // Execute `rustlings hint tests8` or use the `hint` watch subcommand for a
8- // hint.
9-
10- // I AM NOT DONE
11-
12- fn main ( ) { }
13-
14- #[ cfg( test) ]
15- mod tests {
16- use super :: * ;
17-
18- #[ test]
19- fn test_success ( ) {
20- #[ cfg( feature = "pass" ) ]
21- return ;
22-
23- panic ! ( "no cfg set" ) ;
24- }
1+ // build.rs
2+ fn main ( ) {
3+ // 1. 兼容tests7:设置TEST_FOO环境变量(原逻辑保留)
4+ let timestamp = std:: time:: SystemTime :: now ( )
5+ . duration_since ( std:: time:: UNIX_EPOCH )
6+ . unwrap ( )
7+ . as_secs ( ) ;
8+ println ! ( "cargo:rustc-env=TEST_FOO={}" , timestamp) ;
9+
10+ // 2. 兼容tests8:向Cargo输出指令,启用"pass"特性
11+ println ! ( "cargo:rustc-cfg=feature=\" pass\" " ) ;
2512}
You can’t perform that action at this time.
0 commit comments