Compare commits

...

8 commits

Author SHA1 Message Date
Skia
9dd0fd6831 Make sure master's version is different from anything released or packaged 2025-09-09 13:37:04 +02:00
Skia
343998a09d Release 2.3.1
* No changes in swaysome itself, only bugfixes in the tests to make them
  compatible with Debian's autopkgtest.
2025-09-09 13:33:37 +02:00
Skia
317e463da1 tests: workaround rust-lang/rust#46379 2025-09-09 13:18:46 +02:00
Skia
2410c1164d tests: add test_binary_version as a poor safeguard 2025-09-09 13:18:20 +02:00
Skia
3514b9cd5b Cargo.toml: Make sure master's version is different from anything released or packaged 2025-09-09 13:17:57 +02:00
Skia
a83c9d45aa tests: fix error message 2025-09-09 13:05:40 +02:00
Skia
11396b677e 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.
2025-09-09 13:02:10 +02:00
Skia
75806d081f tests: make sure sway's subprocesses are killed before killing sway
This fixes the tests when run within Debian's autopkgtest. Since there
were still some living child processes, autopkgtest was stuck waiting
for them forever.
2025-09-09 12:57:47 +02:00
5 changed files with 38 additions and 11 deletions

2
Cargo.lock generated
View file

@ -187,7 +187,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "swaysome"
version = "2.3.0"
version = "2.3.1+git"
dependencies = [
"assert-json-diff",
"byteorder",

View file

@ -1,6 +1,6 @@
[package]
name = "swaysome"
version = "2.3.0"
version = "2.3.1+git"
authors = ["Skia <skia@hya.sk>", "Nabos <nabos@glargh.fr>"]
edition = "2021"
description = "swaysome provides an awesome way to manage your multiple outputs with the sway windows manager"

View file

@ -1,4 +1,4 @@
.TH SWAYSOME "1" "Sep 2025" "2.3.0" "User Commands"
.TH SWAYSOME "1" "Sep 2025" "2.3.1" "User Commands"
.
.
.SH NAME
@ -142,7 +142,7 @@ Print version
.
.
.SH "VERSION"
2.3.0
2.3.1
.
.
.SH "HOMEPAGE"

View file

@ -3,28 +3,48 @@ use std::process::Command;
mod utils;
use utils::Sway;
static SWAYSOME_BIN: &str = env!("CARGO_BIN_EXE_swaysome");
// Poor safeguard that the tests are actually testing the right version, in
// case there is some confusion with a swaysome installed from the system. That
// obviously does not always worked, but has saved me a couple of times already 🙃
#[test]
fn test_binary_version() {
let output = Command::new(SWAYSOME_BIN)
.args(["--version"])
.env_clear()
.env("SWAYSOCK", "/dev/null")
.output()
.expect("Couldn't run swaysome");
assert_eq!(
String::from_utf8(output.stdout).unwrap(),
format!("swaysome {}\n", env!("CARGO_PKG_VERSION"))
);
}
// 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")
.output()
.expect("Couldn't run swaymsg");
.expect("Couldn't run swaysome");
assert_eq!(String::from_utf8(output.stdout).unwrap(), "Better multimonitor handling for sway\n\nUsage: swaysome <COMMAND>\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())
.output()
.expect("Couldn't run swaymsg");
.expect("Couldn't run swaysome");
assert_eq!(String::from_utf8(output.stderr).unwrap(), "successful connection to socket '/tmp/swaysome_tests/test_binary_interaction_with_sway/swaysock'\nSending command: 'focus output HEADLESS-3' - Command successful\nSending command: 'workspace number 31' - Command successful\nSending command: 'focus output HEADLESS-2' - Command successful\nSending command: 'workspace number 21' - Command successful\nSending command: 'focus output HEADLESS-1' - Command successful\nSending command: 'workspace number 11' - Command successful\n");
}

View file

@ -79,6 +79,9 @@ impl Sway {
.expect("Couldn't run swaymsg")
}
// work around https://github.com/rust-lang/rust/issues/46379
// TODO: maybe implement that: https://momori.dev/posts/organize-rust-integration-tests-without-dead-code-warning/
#[allow(dead_code)]
pub fn spawn_some_apps(&self) {
self.send_command(["exec", "foot -T TERM1"].as_slice());
// Make sure the app are created in the right order.
@ -107,6 +110,10 @@ impl Sway {
}
fn stop(&mut self) {
// in case some apps were spawned, kill them, and give them some time to be killed
self.send_command(["[all] kill"].as_slice());
std::thread::sleep(std::time::Duration::from_millis(500));
// now terminate sway
signal(self.process.id(), "TERM");
match self.check_connection("Unable to connect to") {
Ok(()) => eprintln!("Sway terminated correctly on its own"),