diff --git a/CHANGELOG.md b/CHANGELOG.md index a3939f3c..a4c36c0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fixed panic when calling parallel without arguments [#477](https://github.com/Nukesor/pueue/issues/477) -- Fix typo +- Fixed wrong default location for `pueue_aliases.yml` [#480](https://github.com/Nukesor/pueue/issues/480) +- Fix typos ## [3.3.1] - 2023-10-27 diff --git a/pueue/tests/client/integration/follow.rs b/pueue/tests/client/integration/follow.rs index 90bc06a5..64f3fc44 100644 --- a/pueue/tests/client/integration/follow.rs +++ b/pueue/tests/client/integration/follow.rs @@ -102,39 +102,44 @@ async fn fail_on_non_existing(#[case] read_local_logs: bool) -> Result<()> { Ok(()) } -/// Fail and print an error message when following a non-existing task disappears +/// This test is ignored on apple, since it's super flaky. Somebody has to debug this. #[cfg(not(target = "x86_64-apple-darwin"))] -#[rstest] -#[case(true)] -#[case(false)] -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn fail_on_disappearing(#[case] read_local_logs: bool) -> Result<()> { - let mut daemon = daemon().await?; - set_read_local_logs(&mut daemon, read_local_logs)?; - let shared = &daemon.settings.shared; - - // Add a task echoes something and waits for a while - assert_success(add_task(shared, "echo test && sleep 20").await?); - wait_for_task_condition(shared, 0, |task| task.is_running()).await?; - - // Reset the daemon after 2 seconds. At this point, the client will already be following the - // output and should notice that the task went away.. - // This is a bit hacky, but our client test helper always waits for the command to finish - // and I'm feeling too lazy to add a new helper function now. - let moved_shared = shared.clone(); - tokio::task::spawn(async move { - sleep_ms(2000).await; - // Reset the daemon - send_message(&moved_shared, ResetMessage {}) - .await - .expect("Failed to send Start tasks message"); - }); - - // Execute `follow` and remove the task - // The client should exit with exit code `1`. - let output = run_client_command(shared, &["follow", "0"])?; - - assert_snapshot_matches_stdout("follow__fail_on_disappearing", output.stdout)?; - - Ok(()) +mod non_apple { + use super::*; + + /// Fail and print an error message when following a non-existing task disappears + #[rstest] + #[case(true)] + #[case(false)] + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn fail_on_disappearing(#[case] read_local_logs: bool) -> Result<()> { + let mut daemon = daemon().await?; + set_read_local_logs(&mut daemon, read_local_logs)?; + let shared = &daemon.settings.shared; + + // Add a task echoes something and waits for a while + assert_success(add_task(shared, "echo test && sleep 20").await?); + wait_for_task_condition(shared, 0, |task| task.is_running()).await?; + + // Reset the daemon after 2 seconds. At this point, the client will already be following the + // output and should notice that the task went away.. + // This is a bit hacky, but our client test helper always waits for the command to finish + // and I'm feeling too lazy to add a new helper function now. + let moved_shared = shared.clone(); + tokio::task::spawn(async move { + sleep_ms(2000).await; + // Reset the daemon + send_message(&moved_shared, ResetMessage {}) + .await + .expect("Failed to send Start tasks message"); + }); + + // Execute `follow` and remove the task + // The client should exit with exit code `1`. + let output = run_client_command(shared, &["follow", "0"])?; + + assert_snapshot_matches_stdout("follow__fail_on_disappearing", output.stdout)?; + + Ok(()) + } } diff --git a/pueue_lib/src/settings.rs b/pueue_lib/src/settings.rs index ee1c4c58..2f19cf0a 100644 --- a/pueue_lib/src/settings.rs +++ b/pueue_lib/src/settings.rs @@ -212,11 +212,15 @@ pub struct NestedSettings { pub shared: Shared, } +pub fn default_configuration_directory() -> Option { + dirs::config_dir().map(|dir| dir.join("pueue")) +} + /// Get the default config directory. /// If no config can be found, fallback to the current directory. pub fn configuration_directories() -> Vec { - if let Some(config_dir) = dirs::config_dir() { - vec![config_dir.join("pueue"), PathBuf::from(".")] + if let Some(config_dir) = default_configuration_directory() { + vec![config_dir, PathBuf::from(".")] } else { vec![PathBuf::from(".")] } @@ -269,7 +273,7 @@ impl Shared { pub fn alias_file(&self) -> PathBuf { if let Some(path) = &self.alias_file { expand_home(path) - } else if let Some(config_dir) = dirs::config_dir() { + } else if let Some(config_dir) = default_configuration_directory() { config_dir.join("pueue_aliases.yml") } else { PathBuf::from("pueue_aliases.yml")