Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Update #78

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ regex = { version = "1" }

reqwest = { version = "0.11", features = ["blocking"], optional = true }
ping = { version = "0.5", optional = true }
sysinfo = { version = "0.29", optional = true }
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 }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ the test runner will treat it as the test in Rust and also provide the same summ
The `runtime` feature should be enabled and include as normal dependency, and also include the `libtest-with` with corresponding features in `Cargo.toml`.
```toml
test-with = { version = "0.10", features = ["runtime"] }
libtest-with = { version = "0.6.1-5", features = ["net", "resource", "user", "executable"] }
libtest-with = { version = "0.6.1-6", features = ["net", "resource", "user", "executable"] }
```

Create an example with the following runtime macros (`test_with::runner!`, `#[test_with::module]`, `#[test_with::runtime_env()]`).
Expand Down
2 changes: 1 addition & 1 deletion examples/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ edition = "2021"

[dependencies]
test-with = { path = "../../", features = ["runtime"] }
libtest-with = { version = "0.6.1-5", features = ["net", "resource", "user", "executable"]}
libtest-with = { version = "0.6.1-6", features = ["net", "resource", "user", "executable"]}
44 changes: 22 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//! ```toml
//! [dependencies]
//! test-with = { version = "*", default-features = false, features = ["runtime"] }
//! libtest-with = { version = "0.6.1-5", features = ["net", "resource", "user", "executable"] }
//! libtest-with = { version = "0.6.1-6", features = ["net", "resource", "user", "executable"] }
//! ```
//!
//! ```rust
Expand Down Expand Up @@ -65,8 +65,6 @@ use syn::{parse_macro_input, ItemFn, ItemMod};
#[cfg(feature = "runtime")]
use syn::{Item, ItemStruct, ItemType};

#[cfg(feature = "resource")]
use sysinfo::SystemExt;
#[cfg(feature = "executable")]
use which::which;

Expand Down Expand Up @@ -1451,8 +1449,9 @@ pub fn mem(attr: TokenStream, stream: TokenStream) -> TokenStream {

#[cfg(feature = "resource")]
fn check_mem_condition(mem_size_str: String) -> (bool, String) {
let mut sys = sysinfo::System::new_all();
sys.refresh_all();
let sys = sysinfo::System::new_with_specifics(
sysinfo::RefreshKind::new().with_memory(sysinfo::MemoryRefreshKind::new().with_swap()),
);
let mem_size = match byte_unit::Byte::parse_str(format!("{} B", sys.total_memory()), false) {
Ok(b) => b,
Err(_) => abort_call_site!("memory size description is not correct"),
Expand Down Expand Up @@ -1508,9 +1507,9 @@ pub fn runtime_mem(attr: TokenStream, stream: TokenStream) -> TokenStream {

quote::quote! {
fn #check_ident() -> Result<(), libtest_with::Failed> {
use libtest_with::sysinfo::SystemExt;
let mut sys = libtest_with::sysinfo::System::new_all();
sys.refresh_all();
let sys = libtest_with::sysinfo::System::new_with_specifics(
libtest_with::sysinfo::RefreshKind::new().with_memory(libtest_with::sysinfo::MemoryRefreshKind::new().with_ram()),
);
let mem_size = match libtest_with::byte_unit::Byte::parse_str(format!("{} B", sys.total_memory()), false) {
Ok(b) => b,
Err(_) => panic!("system memory size can not get"),
Expand Down Expand Up @@ -1573,9 +1572,9 @@ pub fn runtime_free_mem(attr: TokenStream, stream: TokenStream) -> TokenStream {

quote::quote! {
fn #check_ident() -> Result<(), libtest_with::Failed> {
use libtest_with::sysinfo::SystemExt;
let mut sys = libtest_with::sysinfo::System::new_all();
sys.refresh_all();
let sys = libtest_with::sysinfo::System::new_with_specifics(
libtest_with::sysinfo::RefreshKind::new().with_memory(libtest_with::sysinfo::MemoryRefreshKind::new().with_ram()),
);
let mem_size = match libtest_with::byte_unit::Byte::parse_str(format!("{} B", sys.free_memory()), false) {
Ok(b) => b,
Err(_) => panic!("system memory size can not get"),
Expand Down Expand Up @@ -1638,9 +1637,9 @@ pub fn runtime_available_mem(attr: TokenStream, stream: TokenStream) -> TokenStr

quote::quote! {
fn #check_ident() -> Result<(), libtest_with::Failed> {
use libtest_with::sysinfo::SystemExt;
let mut sys = libtest_with::sysinfo::System::new_all();
sys.refresh_all();
let sys = libtest_with::sysinfo::System::new_with_specifics(
libtest_with::sysinfo::RefreshKind::new().with_memory(libtest_with::sysinfo::MemoryRefreshKind::new().with_ram()),
);
let mem_size = match libtest_with::byte_unit::Byte::parse_str(format!("{} B", sys.available_memory()), false) {
Ok(b) => b,
Err(_) => panic!("system memory size can not get"),
Expand Down Expand Up @@ -1697,8 +1696,9 @@ pub fn swap(attr: TokenStream, stream: TokenStream) -> TokenStream {

#[cfg(feature = "resource")]
fn check_swap_condition(swap_size_str: String) -> (bool, String) {
let mut sys = sysinfo::System::new_all();
sys.refresh_all();
let sys = sysinfo::System::new_with_specifics(
sysinfo::RefreshKind::new().with_memory(sysinfo::MemoryRefreshKind::new().with_swap()),
);
let swap_size = match byte_unit::Byte::parse_str(format!("{} B", sys.total_swap()), false) {
Ok(b) => b,
Err(_) => abort_call_site!("Swap size description is not correct"),
Expand Down Expand Up @@ -1754,9 +1754,9 @@ pub fn runtime_swap(attr: TokenStream, stream: TokenStream) -> TokenStream {

quote::quote! {
fn #check_ident() -> Result<(), libtest_with::Failed> {
use libtest_with::sysinfo::SystemExt;
let mut sys = libtest_with::sysinfo::System::new_all();
sys.refresh_all();
let sys = libtest_with::sysinfo::System::new_with_specifics(
libtest_with::sysinfo::RefreshKind::new().with_memory(libtest_with::sysinfo::MemoryRefreshKind::new().with_swap()),
);
let swap_size = match libtest_with::byte_unit::Byte::parse_str(format!("{} B", sys.total_swap()), false) {
Ok(b) => b,
Err(_) => panic!("system swap size can not get"),
Expand Down Expand Up @@ -1819,9 +1819,9 @@ pub fn runtime_free_swap(attr: TokenStream, stream: TokenStream) -> TokenStream

quote::quote! {
fn #check_ident() -> Result<(), libtest_with::Failed> {
use libtest_with::sysinfo::SystemExt;
let mut sys = libtest_with::sysinfo::System::new_all();
sys.refresh_all();
let sys = libtest_with::sysinfo::System::new_with_specifics(
libtest_with::sysinfo::RefreshKind::new().with_memory(libtest_with::sysinfo::MemoryRefreshKind::new().with_swap()),
);
let swap_size = match libtest_with::byte_unit::Byte::parse_str(format!("{} B", sys.free_swap()), false) {
Ok(b) => b,
Err(_) => panic!("system swap size can not get"),
Expand Down
Loading