Skip to content

Commit

Permalink
Add #test_with::timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Sep 20, 2024
1 parent 30f4649 commit 48e521f
Show file tree
Hide file tree
Showing 10 changed files with 820 additions and 98 deletions.
60 changes: 57 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "test-with"
version = "0.13.1"
version = "0.14.0"
authors = ["Antonio Yang <[email protected]>"]
edition = "2021"
license = "MIT"
Expand All @@ -26,12 +26,13 @@ sysinfo = { version = "0.30", optional = true }
byte-unit = { version = "5.0", optional = true }
num_cpus = { version = "1.13", optional = true }
which = { version = "5.0", optional = true }
chrono = { version = "0.4", optional = true }

[target.'cfg(not(target_os = "windows"))'.dependencies]
uzers = { version = "0.11.3", optional = true }

[features]
default = ["net", "resource", "user", "executable"]
default = ["net", "resource", "user", "executable", "timezone"]
ign-msg = []

runtime = []
Expand All @@ -42,9 +43,10 @@ icmp = ["ping"]
resource = ["sysinfo", "byte-unit", "num_cpus"]
user = ["uzers"]
executable = ["which"]
timezone = ["chrono"]

[dev-dependencies]
tokio = { version = "1.38.0", features = ["rt", "rt-multi-thread", "macros"] }
serial_test = "3.1.1"
libtest-with = { version = "0.7.0-0", features = ["net", "resource", "user", "executable"] }
libtest-with = { version = "0.7.0-3", features = ["net", "resource", "user", "executable", "timezone"] }
rstest = "0.21.0"
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,24 @@ default will be 60 seconds.
assert!(true);
}
```
## Timezone
Run test case when the machine in specific timezone

```rust
// 0 is for UTC
#[test_with::timezone(0)]
#[test]
fn test_works() {
assert!(true);
}

// 8 for GMT+8, this test only run in the timezone
#[test_with::timezone(+8)]
#[test]
fn test_run_in_TW() {
assert!(true)
}
```

## Relating issues
* [Solve this in runtime][original-issue]
Expand Down
Loading

0 comments on commit 48e521f

Please sign in to comment.