mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-21 18:25:41 +03:00
148 lines
4.2 KiB
Diff
148 lines
4.2 KiB
Diff
Patch-Source: https://github.com/SeaDve/Kooha/pull/206
|
|
--
|
|
diff --git a/Cargo.lock b/Cargo.lock
|
|
index 9c784f2..b006acd 100644
|
|
--- a/Cargo.lock
|
|
+++ b/Cargo.lock
|
|
@@ -134,6 +134,16 @@ version = "0.8.3"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
|
|
|
+[[package]]
|
|
+name = "ctor"
|
|
+version = "0.1.26"
|
|
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
+checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
|
|
+dependencies = [
|
|
+ "quote",
|
|
+ "syn",
|
|
+]
|
|
+
|
|
[[package]]
|
|
name = "field-offset"
|
|
version = "0.3.4"
|
|
@@ -761,6 +771,7 @@ name = "kooha"
|
|
version = "2.2.2"
|
|
dependencies = [
|
|
"anyhow",
|
|
+ "ctor",
|
|
"futures-channel",
|
|
"futures-util",
|
|
"gdk4-wayland",
|
|
diff --git a/Cargo.toml b/Cargo.toml
|
|
index 97518f5..66988ef 100644
|
|
--- a/Cargo.toml
|
|
+++ b/Cargo.toml
|
|
@@ -27,3 +27,6 @@ futures-util = { version = "0.3", default-features = false }
|
|
gsettings-macro = "0.1.11"
|
|
pulse = { package = "libpulse-binding", version = "2.26.0" }
|
|
pulse_glib = { package = "libpulse-glib-binding", version = "2.25.1" }
|
|
+
|
|
+[dev-dependencies]
|
|
+ctor = "0.1.26"
|
|
diff --git a/src/main.rs b/src/main.rs
|
|
index 58a60bf..01c900c 100644
|
|
--- a/src/main.rs
|
|
+++ b/src/main.rs
|
|
@@ -51,6 +51,10 @@ use self::{
|
|
config::{GETTEXT_PACKAGE, LOCALEDIR, RESOURCES_FILE},
|
|
};
|
|
|
|
+#[cfg(test)]
|
|
+#[macro_use]
|
|
+extern crate ctor;
|
|
+
|
|
static THREAD_POOL: Lazy<glib::ThreadPool> = Lazy::new(|| glib::ThreadPool::shared(None).unwrap());
|
|
|
|
fn main() {
|
|
@@ -72,3 +76,32 @@ fn main() {
|
|
let app = Application::new();
|
|
app.run();
|
|
}
|
|
+
|
|
+#[cfg(test)]
|
|
+mod test {
|
|
+ use ctor;
|
|
+ use std::{env, process::Command};
|
|
+
|
|
+ // Run once before tests are executed.
|
|
+ #[ctor]
|
|
+ fn setup_schema() {
|
|
+ let schema_dir = &env::var("GSETTINGS_SCHEMA_DIR")
|
|
+ .unwrap_or(concat!(env!("CARGO_MANIFEST_DIR"), "/data").into());
|
|
+
|
|
+ let output = Command::new("glib-compile-schemas")
|
|
+ .arg(schema_dir)
|
|
+ .output()
|
|
+ .unwrap();
|
|
+
|
|
+ if !output.status.success() {
|
|
+ panic!(
|
|
+ "Failed to compile GSchema for tests; stdout: {}; stderr: {}",
|
|
+ String::from_utf8_lossy(&output.stdout),
|
|
+ String::from_utf8_lossy(&output.stderr)
|
|
+ );
|
|
+ }
|
|
+
|
|
+ env::set_var("GSETTINGS_SCHEMA_DIR", schema_dir);
|
|
+ env::set_var("GSETTINGS_BACKEND", "memory");
|
|
+ }
|
|
+}
|
|
diff --git a/src/meson.build b/src/meson.build
|
|
index 283706b..7237362 100644
|
|
--- a/src/meson.build
|
|
+++ b/src/meson.build
|
|
@@ -64,10 +64,12 @@ test(
|
|
'--target-dir=@0@'.format(cargo_target_dir),
|
|
'--',
|
|
'--nocapture',
|
|
+ '--test-threads=1',
|
|
],
|
|
env: [
|
|
'RUST_BACKTRACE=1',
|
|
'CARGO_HOME=@0@'.format(cargo_home),
|
|
+ 'GSETTINGS_SCHEMA_DIR=@0@/data'.format(meson.project_build_root()),
|
|
'PATH=/app/bin:/usr/bin:/usr/lib/sdk/llvm14/bin:/usr/lib/sdk/rust-stable/bin', # TODO Remove llvm14 once removed in manifest
|
|
],
|
|
timeout: 300, # give cargo more time
|
|
diff --git a/src/settings.rs b/src/settings.rs
|
|
index 0563793..2146fab 100644
|
|
--- a/src/settings.rs
|
|
+++ b/src/settings.rs
|
|
@@ -207,36 +207,8 @@ fn is_accessible(path: &Path) -> bool {
|
|
mod tests {
|
|
use super::*;
|
|
|
|
- use std::{env, process::Command, sync::Once};
|
|
-
|
|
- fn setup_schema() {
|
|
- static INIT: Once = Once::new();
|
|
-
|
|
- INIT.call_once(|| {
|
|
- let schema_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/data");
|
|
-
|
|
- let output = Command::new("glib-compile-schemas")
|
|
- .arg(schema_dir)
|
|
- .output()
|
|
- .unwrap();
|
|
-
|
|
- if !output.status.success() {
|
|
- panic!(
|
|
- "Failed to compile GSchema for tests; stdout: {}; stderr: {}",
|
|
- String::from_utf8_lossy(&output.stdout),
|
|
- String::from_utf8_lossy(&output.stderr)
|
|
- );
|
|
- }
|
|
-
|
|
- env::set_var("GSETTINGS_SCHEMA_DIR", schema_dir);
|
|
- env::set_var("GSETTINGS_BACKEND", "memory");
|
|
- });
|
|
- }
|
|
-
|
|
#[test]
|
|
fn default_profile() {
|
|
- setup_schema();
|
|
-
|
|
assert!(Settings::default().profile().is_some());
|
|
assert!(Settings::default().profile().unwrap().supports_audio());
|
|
}
|