diff --git a/Cargo.lock b/Cargo.lock index 76f61854..d7223a98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1472,25 +1472,6 @@ dependencies = [ "syn 2.0.72", ] -[[package]] -name = "env_filter" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" -dependencies = [ - "log", -] - -[[package]] -name = "env_logger" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" -dependencies = [ - "env_filter", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1631,15 +1612,6 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" -[[package]] -name = "find-crate" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a98bbaacea1c0eb6a0876280051b892eb73594fd90cf3b20e9c817029c57d2" -dependencies = [ - "toml", -] - [[package]] name = "flate2" version = "1.0.31" @@ -2466,8 +2438,8 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d4eb0fbbefb8c428b70680e77ed9013887b17c1d6be366b40f264f956d1a096" dependencies = [ - "iced_core 0.12.3", - "iced_futures 0.12.0", + "iced_core", + "iced_futures", "iced_renderer", "iced_widget", "iced_winit", @@ -2484,17 +2456,6 @@ dependencies = [ "iced", ] -[[package]] -name = "iced_core" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11e1942e28dedee756cc27e67e7a838cdc1e59fb6bf9627ec9f709ab3b135782" -dependencies = [ - "bitflags 1.3.2", - "instant", - "palette 0.6.1", -] - [[package]] name = "iced_core" version = "0.12.3" @@ -2505,7 +2466,7 @@ dependencies = [ "glam", "log", "num-traits", - "palette 0.7.6", + "palette", "raw-window-handle", "smol_str", "thiserror", @@ -2513,18 +2474,6 @@ dependencies = [ "xxhash-rust", ] -[[package]] -name = "iced_futures" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "215d51fa4f70dbb63775d7141243c4d98d4d525d8949695601f8fbac7dcbc04e" -dependencies = [ - "futures", - "log", - "wasm-bindgen-futures", - "wasm-timer", -] - [[package]] name = "iced_futures" version = "0.12.0" @@ -2532,7 +2481,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "370bad88fb3832cbeeb3fa6c486b4701fb7e8da32a753b3101d4ce81fc1d9497" dependencies = [ "futures", - "iced_core 0.12.3", + "iced_core", "log", "tokio", "wasm-bindgen-futures", @@ -2549,8 +2498,8 @@ dependencies = [ "bytemuck", "cosmic-text", "half", - "iced_core 0.12.3", - "iced_futures 0.12.0", + "iced_core", + "iced_futures", "log", "lyon_path", "once_cell", @@ -2561,21 +2510,6 @@ dependencies = [ "xxhash-rust", ] -[[package]] -name = "iced_native" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d012eb06da490fe46a695b39721c20da9643f35cf2ecb9d30618fdeb96170616" -dependencies = [ - "iced_core 0.9.0", - "iced_futures 0.6.0", - "iced_style 0.8.0", - "num-traits", - "thiserror", - "twox-hash", - "unicode-segmentation", -] - [[package]] name = "iced_renderer" version = "0.12.1" @@ -2595,32 +2529,21 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a79f852c01cc6d61663c94379cb3974ac3ad315a28c504e847d573e094f46822" dependencies = [ - "iced_core 0.12.3", - "iced_futures 0.12.0", + "iced_core", + "iced_futures", "raw-window-handle", "thiserror", ] -[[package]] -name = "iced_style" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e37333dc2991201140302cd0d4cea051bd37ca3671d5008ec85df86d232ff30" -dependencies = [ - "iced_core 0.9.0", - "once_cell", - "palette 0.6.1", -] - [[package]] name = "iced_style" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ea42a740915d2a5a9ff9c3aa0bca28b16e9fb660bc8f675eed71d186cadb579" dependencies = [ - "iced_core 0.12.3", + "iced_core", "once_cell", - "palette 0.7.6", + "palette", ] [[package]] @@ -2667,7 +2590,7 @@ checksum = "7e01b2212adecf1cb80e2267f302c0e0c263e55f97812056949199ccf9f0b908" dependencies = [ "iced_renderer", "iced_runtime", - "iced_style 0.12.1", + "iced_style", "num-traits", "thiserror", "unicode-segmentation", @@ -2681,7 +2604,7 @@ checksum = "63f66831d0e399b93f631739121a6171780d344b275d56808b9504d8ca75c7d2" dependencies = [ "iced_graphics", "iced_runtime", - "iced_style 0.12.1", + "iced_style", "log", "thiserror", "tracing", @@ -3901,18 +3824,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "palette" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f9cd68f7112581033f157e56c77ac4a5538ec5836a2e39284e65bd7d7275e49" -dependencies = [ - "approx", - "num-traits", - "palette_derive 0.6.1", - "phf", -] - [[package]] name = "palette" version = "0.7.6" @@ -3921,22 +3832,10 @@ checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6" dependencies = [ "approx", "fast-srgb8", - "palette_derive 0.7.6", + "palette_derive", "phf", ] -[[package]] -name = "palette_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05eedf46a8e7c27f74af0c9cfcdb004ceca158cb1b918c6f68f8d7a549b3e427" -dependencies = [ - "find-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "palette_derive" version = "0.7.6" @@ -4123,18 +4022,16 @@ dependencies = [ [[package]] name = "pigg" -version = "0.3.2" +version = "0.3.3" dependencies = [ "anyhow", "chrono", "clap", "derive_more", - "env_logger", "futures-lite 2.3.0", "iced", "iced_aw", - "iced_futures 0.12.0", - "iced_native", + "iced_futures", "iroh-net", "log", "lyon_algorithms", @@ -6129,15 +6026,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml_datetime" version = "0.6.8" @@ -6262,16 +6150,6 @@ dependencies = [ "linked-hash-map", ] -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "static_assertions", -] - [[package]] name = "typenum" version = "1.17.0" diff --git a/Cargo.toml b/Cargo.toml index 7971298b..4b45f15f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pigg" -version = "0.3.2" +version = "0.3.3" edition = "2021" description = "A Graphical User Interface for interacting with local and remote Raspberry Pi Hardware" default-run = "piggui" @@ -41,7 +41,6 @@ tokio = { version = "1.39.2", default-features = false, features = ["time", "rt" # used in piglet only log = { version = "0.4.22", default-features = false } -env_logger = { version = "0.11.5", default-features = false } service-manager = { version = "0.7.1", default-features = false } sysinfo = { version = "0.31.2", default-features = false, features = ["system"] } @@ -49,7 +48,6 @@ sysinfo = { version = "0.31.2", default-features = false, features = ["system"] iced = { version = "0.12.1", default-features = false, features = ["tokio", "debug", "canvas", "advanced"] } iced_aw = { version = "0.9.3", default-features = false, features = ["tabs", "card", "modal", "menu"] } iced_futures = { version = "0.12.0", default-features = false } -iced_native = { version = "0.10.3", default-features = false } plotters-iced = { version = "0.10", default-features = false } plotters = { version = "0.3", default_features = false, features = [ "chrono", diff --git a/Makefile b/Makefile index 17c52861..21b6fe1c 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,6 @@ all: clippy build test .PHONY: cross cross: cross-clippy cross-build cross-test cross-release-build cross-build-armv7 cross-release-build-armv7 -release: release-build - .PHONY: clippy clippy: cargo clippy --tests --no-deps @@ -35,19 +33,19 @@ build: .PHONY: run run: - cargo run --bin piggui + cargo run .PHONY: run-release run-release: - cargo run --bin piggui --release + cargo run --release .PHONY: run-piglet run-piglet: - RUST_LOG=piglet=info cargo run --bin piglet + cargo run --bin piglet .PHONY: run-release-piglet run-release-piglet: - RUST_LOG=piglet=info cargo run --bin piglet --release + cargo run --bin piglet --release # This will build all binaries on the current host, be it macos, linux or raspberry pi - with release profile .PHONY: build-release @@ -55,7 +53,7 @@ build-release: cargo build --release # This will only test GUI tests in piggui on the local host, whatever that is -# We'd need to think how to run tests on RPi, on piggui with GUI and GPIO functionality, and piglet with GPIO functionality +# We'd need to think how to run tests on RºPi, on piggui with GUI and GPIO functionality, and piglet with GPIO functionality .PHONY: test test: cargo test diff --git a/src/piglet.rs b/src/piglet.rs index e28c9351..560bc030 100644 --- a/src/piglet.rs +++ b/src/piglet.rs @@ -224,7 +224,7 @@ async fn listen(info_path: &Path, mut hardware: impl Hardware) -> anyhow::Result .await?; let nodeid = endpoint.node_id(); - info!("node id: {nodeid}"); + println!("nodeid: {nodeid}"); let local_addrs = endpoint .direct_addresses() @@ -235,12 +235,12 @@ async fn listen(info_path: &Path, mut hardware: impl Hardware) -> anyhow::Result .map(|endpoint| endpoint.addr.to_string()) .collect::>() .join(" "); - info!("local Addresses: {local_addrs}"); + println!("local Addresses: {local_addrs}"); let relay_url = endpoint .home_relay() .expect("should be connected to a relay server, try calling `endpoint.local_endpoints()` or `endpoint.connect()` first, to ensure the endpoint has actually attempted a connection before checking for the connected relay server"); - info!("node relay server url: {relay_url}"); + println!("Relay URL: {relay_url}"); // write the info about the node to the info_path file for use in piggui write_info_file(info_path, &nodeid, &local_addrs, &relay_url)?; diff --git a/tests/piglet.rs b/tests/piglet.rs new file mode 100644 index 00000000..2c11bf5b --- /dev/null +++ b/tests/piglet.rs @@ -0,0 +1,59 @@ +use std::io::{BufRead, BufReader}; +use std::path::PathBuf; +use std::process::{Command, Stdio}; + +pub fn run_piglet(config: Option) -> String { + let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let mut piglet_command = Command::new("cargo"); + + let mut args = vec!["run".to_string(), "--bin".to_string(), "piglet".to_string()]; + + // If a config file path was supplied, add it as a CLI argument + if let Some(config_path) = config { + args.push("--".to_string()); + let path = config_path.as_path().to_string_lossy().to_string(); + args.push(path); + } + + println!("Running Command: cargo {}", args.join(" ")); + + // spawn the 'piglet' process + let mut server = piglet_command + .args(args) + .current_dir(crate_dir) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("Failed to spawn piglet"); + + let stdout = server + .stdout + .as_mut() + .expect("Could not read stdout of piglet"); + let mut reader = BufReader::new(stdout); + let mut output = String::new(); + reader + .read_line(&mut output) + .expect("Could not read stdout of piglet"); + + println!("Killing 'piglet'"); + server.kill().expect("Failed to kill piglet process"); + + output +} + +#[cfg(not(all( + target_os = "linux", + any(target_arch = "aarch64", target_arch = "arm"), + target_env = "gnu" +)))] +#[test] +fn node_id_is_output() { + let output = run_piglet(None); + println!("Output: {}", output); + assert!( + output.contains("nodeid"), + "Output of piglet does not contain nodeid" + ); +}