-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests #206
base: main
Are you sure you want to change the base?
Fix tests #206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -51,6 +51,10 @@ use self::{ | |||||
config::{GETTEXT_PACKAGE, LOCALEDIR, RESOURCES_FILE}, | ||||||
}; | ||||||
|
||||||
#[cfg(test)] | ||||||
#[macro_use] | ||||||
extern crate ctor; | ||||||
|
||||||
fn main() -> glib::ExitCode { | ||||||
tracing_subscriber::fmt::init(); | ||||||
|
||||||
|
@@ -70,3 +74,32 @@ fn main() -> glib::ExitCode { | |||||
let app = Application::new(); | ||||||
app.run() | ||||||
} | ||||||
|
||||||
#[cfg(test)] | ||||||
mod test { | ||||||
use ctor; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as this |
||||||
use std::{env, process::Command}; | ||||||
|
||||||
// Run once before tests are executed. | ||||||
#[ctor] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
or use ctor::ctor;
#[ctor]
fn setup_schema() {
...
} |
||||||
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"); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,9 +59,11 @@ test( | |
cargo_options, | ||
'--', | ||
'--nocapture', | ||
'--test-threads=1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still required, even though gtk tests already run single threaded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't add it if it wasn't needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still not sure why this is still needed |
||
], | ||
env: [ | ||
'RUST_BACKTRACE=1', | ||
'GSETTINGS_SCHEMA_DIR=@0@/data'.format(meson.project_build_root()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be needed too since it is set on |
||
cargo_env | ||
], | ||
timeout: 300, # give cargo more time | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not needed.