103 lines
3.8 KiB
Diff
103 lines
3.8 KiB
Diff
From cf4539ac602c1bcf7dc1bf1664cba60118ccd576 Mon Sep 17 00:00:00 2001
|
|
From: licunlong <licunlong1@huawei.com>
|
|
Date: Fri, 30 Jun 2023 10:57:34 +0800
|
|
Subject: [PATCH] fix: avoid calling init_lookup_paths in testcase
|
|
|
|
We know where our testcases are, so just push the directory into our search_path
|
|
---
|
|
core/bin/manager/pre_install.rs | 14 ++++++++++++--
|
|
core/bin/unit/entry/uentry.rs | 7 ++++++-
|
|
core/bin/unit/manager.rs | 7 ++++++-
|
|
core/bin/unit/test/mod.rs | 7 ++++++-
|
|
4 files changed, 30 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/core/bin/manager/pre_install.rs b/core/bin/manager/pre_install.rs
|
|
index 7762ecb..88150c0 100644
|
|
--- a/core/bin/manager/pre_install.rs
|
|
+++ b/core/bin/manager/pre_install.rs
|
|
@@ -796,7 +796,12 @@ mod test {
|
|
#[test]
|
|
fn test_read_presets() {
|
|
let mut l_path = LookupPaths::new();
|
|
- l_path.init_lookup_paths();
|
|
+ let test_preset_dir = libtests::get_project_root()
|
|
+ .unwrap()
|
|
+ .join("tests/presets")
|
|
+ .to_string_lossy()
|
|
+ .to_string();
|
|
+ l_path.preset_path.push(test_preset_dir);
|
|
let lookup_path = Rc::new(l_path);
|
|
|
|
let install = Install::new(PresetMode::Enable, lookup_path);
|
|
@@ -815,7 +820,12 @@ mod test {
|
|
#[test]
|
|
fn test_preset_all() {
|
|
let mut l_path = LookupPaths::new();
|
|
- l_path.init_lookup_paths();
|
|
+ let test_preset_dir = libtests::get_project_root()
|
|
+ .unwrap()
|
|
+ .join("tests/presets")
|
|
+ .to_string_lossy()
|
|
+ .to_string();
|
|
+ l_path.preset_path.push(test_preset_dir);
|
|
let lookup_path = Rc::new(l_path);
|
|
let install = Install::new(PresetMode::Enable, lookup_path);
|
|
assert!(install.preset_all().is_ok());
|
|
diff --git a/core/bin/unit/entry/uentry.rs b/core/bin/unit/entry/uentry.rs
|
|
index 45f0e57..d2f5369 100644
|
|
--- a/core/bin/unit/entry/uentry.rs
|
|
+++ b/core/bin/unit/entry/uentry.rs
|
|
@@ -783,7 +783,12 @@ mod tests {
|
|
let rentry = Rc::new(UnitRe::new(&reli));
|
|
|
|
let mut l_path = LookupPaths::new();
|
|
- l_path.init_lookup_paths();
|
|
+ let test_units_dir = libtests::get_project_root()
|
|
+ .unwrap()
|
|
+ .join("tests/test_units/")
|
|
+ .to_string_lossy()
|
|
+ .to_string();
|
|
+ l_path.search_path.push(test_units_dir);
|
|
let lookup_path = Rc::new(l_path);
|
|
let unit_file = UnitFile::new(&lookup_path);
|
|
|
|
diff --git a/core/bin/unit/manager.rs b/core/bin/unit/manager.rs
|
|
index 73fb593..0a3549f 100644
|
|
--- a/core/bin/unit/manager.rs
|
|
+++ b/core/bin/unit/manager.rs
|
|
@@ -1403,7 +1403,12 @@ mod tests {
|
|
fn init_dm_for_test() -> (Rc<DataManager>, Rc<Events>, Rc<UnitManager>) {
|
|
logger::init_log_to_console("manager test", log::LevelFilter::Trace);
|
|
let mut l_path = LookupPaths::new();
|
|
- l_path.init_lookup_paths();
|
|
+ let test_units_dir = libtests::get_project_root()
|
|
+ .unwrap()
|
|
+ .join("tests/test_units/")
|
|
+ .to_string_lossy()
|
|
+ .to_string();
|
|
+ l_path.search_path.push(test_units_dir);
|
|
let lookup_path = Rc::new(l_path);
|
|
|
|
let event = Rc::new(Events::new().unwrap());
|
|
diff --git a/core/bin/unit/test/mod.rs b/core/bin/unit/test/mod.rs
|
|
index 8f2d120..2138ab6 100644
|
|
--- a/core/bin/unit/test/mod.rs
|
|
+++ b/core/bin/unit/test/mod.rs
|
|
@@ -32,7 +32,12 @@ pub(crate) mod test_utils {
|
|
name: &str,
|
|
) -> Rc<UnitX> {
|
|
let mut l_path = LookupPaths::new();
|
|
- l_path.init_lookup_paths();
|
|
+ let test_units_dir = libtests::get_project_root()
|
|
+ .unwrap()
|
|
+ .join("tests/test_units/")
|
|
+ .to_string_lossy()
|
|
+ .to_string();
|
|
+ l_path.search_path.push(test_units_dir);
|
|
let lookup_path = Rc::new(l_path);
|
|
|
|
let file = Rc::new(UnitFile::new(&lookup_path));
|
|
--
|
|
2.33.0
|
|
|