[librsvg: 43/53] Initialize the system language for tests




commit 67160800731cbc47fb7becdaec66c191212cadf0
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Oct 22 17:24:04 2020 -0500

    Initialize the system language for tests
    
    This is just the lazy thing.  Like in rsvg-test.c, we set environment
    variables for the system language and run all the tests against that.
    A cleaner / less egregious version would separate out the
    language-specific tests, but for now this works fine.
    
    With this, all the tests pass!!!

 tests/src/reference.rs |  3 ++-
 tests/src/utils.rs     | 12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/tests/src/reference.rs b/tests/src/reference.rs
index 228ff8eb..cf961b15 100644
--- a/tests/src/reference.rs
+++ b/tests/src/reference.rs
@@ -16,7 +16,7 @@ use std::fs::File;
 use std::io::BufReader;
 use std::path::PathBuf;
 
-use crate::utils::{fixture_path, setup_font_map};
+use crate::utils::{fixture_path, setup_font_map, setup_language};
 
 use self::duplicated_from_librsvg_crate::compare_to_file;
 
@@ -37,6 +37,7 @@ const TEST_SUITE_DPI: f64 = 72.0;
 const FRAME_SIZE: i32 = 47;
 
 fn reference_test(name: &str) {
+    setup_language();
     setup_font_map();
 
     let path = fixture_path(name);
diff --git a/tests/src/utils.rs b/tests/src/utils.rs
index d2628098..856a9c14 100644
--- a/tests/src/utils.rs
+++ b/tests/src/utils.rs
@@ -5,6 +5,7 @@ use libc;
 use std::env;
 use std::ffi::CString;
 use std::path::PathBuf;
+use std::sync::Once;
 
 #[cfg(have_pangoft2)]
 
@@ -84,3 +85,14 @@ pub fn setup_font_map() {
 
 #[cfg(not(have_pangoft2))]
 pub fn setup_font_map() {}
+
+pub fn setup_language() {
+    static ONCE: Once = Once::new();
+
+    ONCE.call_once(|| {
+        // For systemLanguage attribute tests.
+        // The trailing ":" is intentional to test gitlab#425.
+        env::set_var("LANGUAGE", "de:en_US:en:");
+        env::set_var("LC_ALL", "de:en_US:en:");
+    });
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]