11//! This is the build script for both tests7 and tests8.
22//!
33//! You should modify this file to make both exercises pass.
4-
4+ use std:: time:: SystemTime ;
5+ use std:: env;
56fn main ( ) {
67 // In tests7, we should set up an environment variable
78 // called `TEST_FOO`. Print in the standard output to let
@@ -10,15 +11,25 @@ fn main() {
1011 . duration_since ( std:: time:: UNIX_EPOCH )
1112 . unwrap ( )
1213 . as_secs ( ) ; // What's the use of this timestamp here?
13- let your_command = format ! (
14- "Your command here with {}, please checkout exercises/tests/build.rs" ,
15- timestamp
16- ) ;
17- println ! ( "cargo:{}" , your_command) ;
14+ // let your_command = format!(
15+ // //"Your command here with {}, please checkout exercises/tests/build.rs",
16+ //
17+ // timestamp
18+ // );
19+ // println!("cargo:{}", your_command);
20+ //
21+ // // In tests8, we should enable "pass" feature to make the
22+ // // testcase return early. Fill in the command to tell
23+ // // Cargo about that.
24+ // let your_command = "Your command here, please checkout exercises/tests/build.rs";
25+ // println!("cargo:{}", your_command);
26+ // 修正:直接使用 Cargo 专属格式设置 TEST_FOO 环境变量(移除错误的 format! 嵌套 println!)
27+ println ! ( "cargo:rustc-env=TEST_FOO={}" , timestamp) ;
1828
1929 // In tests8, we should enable "pass" feature to make the
2030 // testcase return early. Fill in the command to tell
2131 // Cargo about that.
22- let your_command = "Your command here, please checkout exercises/tests/build.rs" ;
32+ // 启用 "pass" 特性的 Cargo 指令
33+ let your_command = "rustc-cfg=feature=\" pass\" " ;
2334 println ! ( "cargo:{}" , your_command) ;
2435}
0 commit comments