Skip to content

Commit e4ef04f

Browse files
authored
Update tests8.rs
1 parent dafbad4 commit e4ef04f

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

exercises/tests/tests8.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
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
}

0 commit comments

Comments
 (0)