From 11396b677eb1b867fb30980f5cabeeaacb2ef868 Mon Sep 17 00:00:00 2001 From: Skia Date: Tue, 9 Sep 2025 13:02:09 +0200 Subject: [PATCH] tests: make use of 'CARGO_BIN_EXE_swaysome' Instead of hardcoding a relative and making assumptions, this makes sure the tests are calling the right binary. --- tests/integration_bin.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/integration_bin.rs b/tests/integration_bin.rs index 868dfd4..2454c6f 100644 --- a/tests/integration_bin.rs +++ b/tests/integration_bin.rs @@ -3,9 +3,12 @@ use std::process::Command; mod utils; use utils::Sway; +static SWAYSOME_BIN: &str = env!("CARGO_BIN_EXE_swaysome"); + +// This is useful when working on swapping argument parsing libraries. #[test] fn test_binary_help() { - let output = Command::new("./target/debug/swaysome") + let output = Command::new(SWAYSOME_BIN) .args(["-h"]) .env_clear() .env("SWAYSOCK", "/dev/null") @@ -14,13 +17,13 @@ fn test_binary_help() { assert_eq!(String::from_utf8(output.stdout).unwrap(), "Better multimonitor handling for sway\n\nUsage: swaysome \n\nCommands:\n init Initialize the workspace groups for all the outputs\n move Move the focused container to another workspace on the same workspace group\n move-to-group Move the focused container to the same workspace index on another workspace group\n focus Focus to another workspace on the same workspace group\n focus-group Focus to workspace group\n focus-all-outputs Focus to another workspace on all the outputs\n next-output Move the focused container to the next output\n prev-output Move the focused container to the previous output\n workspace-group-next-output Move the focused workspace group to the next output\n workspace-group-prev-output Move the focused workspace group to the previous output\n next-group Move the focused container to the next group\n prev-group Move the focused container to the previous group\n rearrange-workspaces Rearrange already opened workspaces to the correct outputs, useful when plugging new monitors\n help Print this message or the help of the given subcommand(s)\n\nOptions:\n -h, --help Print help\n -V, --version Print version\n"); } -/// We only test the 'init' command, given that the exhaustive command testing -/// is done in the library integration tests. Here, we only verify that the -/// interaction with `sway` works seamslessly. +// We only test the 'init' command, given that the exhaustive command testing +// is done in the library integration tests. Here, we only verify that the +// interaction with `sway` works seamslessly. #[test] fn test_binary_interaction_with_sway() { let sway = Sway::start(); - let output = Command::new("./target/debug/swaysome") + let output = Command::new(SWAYSOME_BIN) .args(["init", "1"]) .env_clear() .env("SWAYSOCK", sway.sock.clone())