aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/yt/tests/_testenv/init.rs42
-rw-r--r--crates/yt/tests/_testenv/mod.rs1
-rw-r--r--crates/yt/tests/_testenv/run.rs5
-rw-r--r--crates/yt/tests/subscriptions/import_export/golden.txt4
-rw-r--r--crates/yt/tests/subscriptions/naming_subscriptions/golden.txt4
5 files changed, 37 insertions, 19 deletions
diff --git a/crates/yt/tests/_testenv/init.rs b/crates/yt/tests/_testenv/init.rs
index ff88d46..93b1d4d 100644
--- a/crates/yt/tests/_testenv/init.rs
+++ b/crates/yt/tests/_testenv/init.rs
@@ -10,25 +10,32 @@
// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
use std::{
- env,
- fs::{self, OpenOptions},
- io::{self, Write},
- path::PathBuf,
+ env, fs::{self, OpenOptions, Permissions}, io::{self, Write}, os::unix::fs::PermissionsExt, path::PathBuf, process::Command,
};
use crate::{_testenv::Paths, testenv::TestEnv};
fn target_dir() -> PathBuf {
- // Tests exe is in target/debug/deps, the *yt* exe is in target/debug
- env::current_exe()
- .expect("./target/debug/deps/yt-*")
- .parent()
- .expect("./target/debug/deps")
- .parent()
- .expect("./target/debug")
- .parent()
- .expect("./target")
- .to_path_buf()
+ let root = {
+ let output = Command::new("git")
+ .args(["rev-parse", "--show-toplevel"])
+ .output()
+ .expect("git failed");
+
+ assert!(output.status.success());
+
+ PathBuf::from(
+ String::from_utf8(output.stdout)
+ .expect("git not utf8")
+ .trim(),
+ )
+ };
+
+ let target = root.join("target");
+
+ assert!(target.is_dir());
+
+ target
}
fn test_dir(name: &'static str) -> PathBuf {
@@ -44,6 +51,7 @@ fn prepare_files_and_dirs(name: &'static str) -> io::Result<Paths> {
let last_selection_path = test_dir.join("last_selection");
let config_path = test_dir.join("config.toml");
let download_dir = test_dir.join("download");
+ let runtime = test_dir.join("xdg_runtime");
{
// Remove all files, that are not the download dir.
@@ -64,6 +72,11 @@ fn prepare_files_and_dirs(name: &'static str) -> io::Result<Paths> {
}
fs::create_dir_all(&download_dir)?;
+ fs::create_dir_all(&runtime)?;
+ fs::set_permissions(
+ &runtime,
+ Permissions::from_mode(0o700),
+ )?;
{
let mut config_file = OpenOptions::new()
@@ -99,6 +112,7 @@ max_backlog = 1
last_selection: last_selection_path,
config: config_path,
download_dir,
+ runtime,
})
}
diff --git a/crates/yt/tests/_testenv/mod.rs b/crates/yt/tests/_testenv/mod.rs
index adf17ca..4ef3f97 100644
--- a/crates/yt/tests/_testenv/mod.rs
+++ b/crates/yt/tests/_testenv/mod.rs
@@ -33,4 +33,5 @@ pub(crate) struct Paths {
pub(crate) last_selection: PathBuf,
pub(crate) config: PathBuf,
pub(crate) download_dir: PathBuf,
+ pub(crate) runtime: PathBuf,
}
diff --git a/crates/yt/tests/_testenv/run.rs b/crates/yt/tests/_testenv/run.rs
index b313353..ac0a5b3 100644
--- a/crates/yt/tests/_testenv/run.rs
+++ b/crates/yt/tests/_testenv/run.rs
@@ -162,12 +162,15 @@ impl TestEnv {
cmd.args([
"-v",
- "--color",
+ "--option",
+ "global.display_colors",
"false",
"--config-path",
self.paths.config.to_str().unwrap(),
]);
+ cmd.env("XDG_RUNTIME_DIR", self.paths.runtime.clone());
+
cmd.stdout(Stdio::piped());
cmd.stderr(Stdio::piped());
diff --git a/crates/yt/tests/subscriptions/import_export/golden.txt b/crates/yt/tests/subscriptions/import_export/golden.txt
index 7ed5419..c98b723 100644
--- a/crates/yt/tests/subscriptions/import_export/golden.txt
+++ b/crates/yt/tests/subscriptions/import_export/golden.txt
@@ -1,2 +1,2 @@
-Nyheter på lätt svenska: 'https://www.svtplay.se/nyheter-pa-latt-svenska'
-tagesschau: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU'
+Nyheter på lätt svenska: 'https://www.svtplay.se/nyheter-pa-latt-svenska' (active)
+tagesschau: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU' (active)
diff --git a/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt b/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt
index 46ede50..6be5e23 100644
--- a/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt
+++ b/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt
@@ -1,2 +1,2 @@
-Nyheter: 'https://www.svtplay.se/nyheter-pa-latt-svenska'
-Vewn: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU'
+Nyheter: 'https://www.svtplay.se/nyheter-pa-latt-svenska' (active)
+Vewn: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU' (active)