diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-12-01 16:14:03 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-12-01 16:14:03 +0300 |
| commit | 26207917ec6b1011eb8348c9a05d31be3a6a2d9f (patch) | |
| tree | c35a1f24df842357c7258788b0cb10cd9b791ceb | |
| parent | d979b6da3622b458922a7a57b3e7aaf18fcab291 (diff) | |
Added the ability to transfer config through an environment variable
| -rw-r--r-- | .woodpecker.yaml | 1 | ||||
| -rw-r--r-- | NamelessTeam-mesk-20-tests.log | 417 | ||||
| -rw-r--r-- | src/cfg/config.rs | 15 | ||||
| -rw-r--r-- | tests/shared.rs | 5 |
4 files changed, 436 insertions, 2 deletions
diff --git a/.woodpecker.yaml b/.woodpecker.yaml index 989ec3c..14ad9df 100644 --- a/.woodpecker.yaml +++ b/.woodpecker.yaml @@ -39,6 +39,7 @@ steps: environment: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always + MESK_CONFIG_TOML: "[repo]\nrepo_url = \"https://mesk.anthrill.i2p/repo/x86_64/\"\nauto_update = true\ndestination = (\"mesk\", \"mesk\")" commands: - cargo test --verbose --jobs 2 when: diff --git a/NamelessTeam-mesk-20-tests.log b/NamelessTeam-mesk-20-tests.log new file mode 100644 index 0000000..7eb5543 --- /dev/null +++ b/NamelessTeam-mesk-20-tests.log @@ -0,0 +1,417 @@ +[1m[92m Finished[0m `test` profile [unoptimized + debuginfo] target(s) in 1m 15s +[1m[92m Running[0m `/woodpecker/src/codeberg.org/NamelessTeam/mesk/target/debug/deps/mesk-2938a805b2bb07a9` + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + +[1m[92m Running[0m `/woodpecker/src/codeberg.org/NamelessTeam/mesk/target/debug/deps/mesk-59b19840b86ece8c` + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + +[1m[92m Running[0m `/woodpecker/src/codeberg.org/NamelessTeam/mesk/target/debug/deps/http_funcs-b6c3ad6046dea909` + +running 4 tests +test http_package_tests::test_http_fetch_package_info_success ... ok +test http_package_tests::test_http_fetch_package_info_not_found ... ok +test http_package_tests::test_http_fetch_index_http_error ... ok +test http_package_tests::test_http_fetch_index_success ... ok + +test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s + +[1m[92m Running[0m `/woodpecker/src/codeberg.org/NamelessTeam/mesk/target/debug/deps/i2p_functions-cfc4624453f3e34c` + +running 2 tests +test i2p_package_tests::test_i2p_fetch_package_info_not_found ... ok +test i2p_package_tests::test_i2p_fetch_package_info_success ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + +[1m[92m Running[0m `/woodpecker/src/codeberg.org/NamelessTeam/mesk/target/debug/deps/pkgtoolkit_funcs-42684ac60188fc1d` + +running 6 tests +test package_tests::test_archs_as_str ... ok +test package_tests::test_package_check_arch_mismatch ... FAILED +test package_tests::test_package_check_empty_install ... FAILED +test package_tests::test_extract_archive ... FAILED +test package_tests::test_package_check_missing_install ... FAILED +test package_tests::test_package_check_valid ... FAILED + +failures: + +---- package_tests::test_package_check_arch_mismatch stdout ---- + +thread 'package_tests::test_package_check_arch_mismatch' (3321) panicked at src/cfg/config.rs:59:66: +called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" } +stack backtrace: + 0: __rustc::rust_begin_unwind + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:698:5 + 1: core::panicking::panic_fmt + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/panicking.rs:75:14 + 2: core::result::unwrap_failed + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1855:5 + 3: core::result::Result<T,E>::unwrap + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1226:23 + 4: mesk::cfg::config::Config::parse + at ./src/cfg/config.rs:59:66 + 5: mesk::pkgtoolkit::pkgtools::Package::extract_archive + at ./src/pkgtoolkit/pkgtools.rs:168:22 + 6: mesk::pkgtoolkit::pkgtools::Package::check + at ./src/pkgtoolkit/pkgtools.rs:306:9 + 7: pkgtoolkit_funcs::package_tests::test_package_check_arch_mismatch::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:210:22 + 8: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 9: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:70 + 11: tokio::task::coop::with_budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:167:5 + 12: tokio::task::coop::budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:133:5 + 13: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:25 + 14: tokio::runtime::scheduler::current_thread::Context::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:432:19 + 15: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:741:44 + 16: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:68 + 17: tokio::runtime::context::scoped::Scoped<T>::set + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/scoped.rs:40:9 + 18: tokio::runtime::context::set_scheduler::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:38 + 19: std::thread::local::LocalKey<T>::try_with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:315:12 + 20: std::thread::local::LocalKey<T>::with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:279:20 + 21: tokio::runtime::context::set_scheduler + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:17 + 22: tokio::runtime::scheduler::current_thread::CoreGuard::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:27 + 23: tokio::runtime::scheduler::current_thread::CoreGuard::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:729:24 + 24: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:200:33 + 25: tokio::runtime::context::runtime::enter_runtime + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/runtime.rs:65:16 + 26: tokio::runtime::scheduler::current_thread::CurrentThread::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:188:9 + 27: tokio::runtime::runtime::Runtime::block_on_inner + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:368:52 + 28: tokio::runtime::runtime::Runtime::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:342:18 + 29: pkgtoolkit_funcs::package_tests::test_package_check_arch_mismatch + at ./tests/pkgtoolkit_funcs.rs:212:22 + 30: pkgtoolkit_funcs::package_tests::test_package_check_arch_mismatch::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:172:48 + 31: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 + 32: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +---- package_tests::test_package_check_empty_install stdout ---- + +thread 'package_tests::test_package_check_empty_install' (3322) panicked at src/cfg/config.rs:59:66: +called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" } +stack backtrace: + 0: __rustc::rust_begin_unwind + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:698:5 + 1: core::panicking::panic_fmt + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/panicking.rs:75:14 + 2: core::result::unwrap_failed + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1855:5 + 3: core::result::Result<T,E>::unwrap + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1226:23 + 4: mesk::cfg::config::Config::parse + at ./src/cfg/config.rs:59:66 + 5: mesk::pkgtoolkit::pkgtools::Package::extract_archive + at ./src/pkgtoolkit/pkgtools.rs:168:22 + 6: mesk::pkgtoolkit::pkgtools::Package::check + at ./src/pkgtoolkit/pkgtools.rs:306:9 + 7: pkgtoolkit_funcs::package_tests::test_package_check_empty_install::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:154:22 + 8: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 9: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:70 + 11: tokio::task::coop::with_budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:167:5 + 12: tokio::task::coop::budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:133:5 + 13: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:25 + 14: tokio::runtime::scheduler::current_thread::Context::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:432:19 + 15: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:741:44 + 16: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:68 + 17: tokio::runtime::context::scoped::Scoped<T>::set + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/scoped.rs:40:9 + 18: tokio::runtime::context::set_scheduler::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:38 + 19: std::thread::local::LocalKey<T>::try_with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:315:12 + 20: std::thread::local::LocalKey<T>::with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:279:20 + 21: tokio::runtime::context::set_scheduler + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:17 + 22: tokio::runtime::scheduler::current_thread::CoreGuard::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:27 + 23: tokio::runtime::scheduler::current_thread::CoreGuard::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:729:24 + 24: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:200:33 + 25: tokio::runtime::context::runtime::enter_runtime + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/runtime.rs:65:16 + 26: tokio::runtime::scheduler::current_thread::CurrentThread::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:188:9 + 27: tokio::runtime::runtime::Runtime::block_on_inner + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:368:52 + 28: tokio::runtime::runtime::Runtime::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:342:18 + 29: pkgtoolkit_funcs::package_tests::test_package_check_empty_install + at ./tests/pkgtoolkit_funcs.rs:156:22 + 30: pkgtoolkit_funcs::package_tests::test_package_check_empty_install::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:140:48 + 31: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 + 32: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +---- package_tests::test_extract_archive stdout ---- + +thread 'package_tests::test_extract_archive' (3320) panicked at src/cfg/config.rs:59:66: +called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" } +stack backtrace: + 0: __rustc::rust_begin_unwind + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:698:5 + 1: core::panicking::panic_fmt + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/panicking.rs:75:14 + 2: core::result::unwrap_failed + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1855:5 + 3: core::result::Result<T,E>::unwrap + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1226:23 + 4: mesk::cfg::config::Config::parse + at ./src/cfg/config.rs:59:66 + 5: mesk::pkgtoolkit::pkgtools::Package::extract_archive + at ./src/pkgtoolkit/pkgtools.rs:168:22 + 6: pkgtoolkit_funcs::package_tests::test_extract_archive::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:44:15 + 7: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 8: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 9: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:70 + 10: tokio::task::coop::with_budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:167:5 + 11: tokio::task::coop::budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:133:5 + 12: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:25 + 13: tokio::runtime::scheduler::current_thread::Context::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:432:19 + 14: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:741:44 + 15: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:68 + 16: tokio::runtime::context::scoped::Scoped<T>::set + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/scoped.rs:40:9 + 17: tokio::runtime::context::set_scheduler::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:38 + 18: std::thread::local::LocalKey<T>::try_with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:315:12 + 19: std::thread::local::LocalKey<T>::with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:279:20 + 20: tokio::runtime::context::set_scheduler + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:17 + 21: tokio::runtime::scheduler::current_thread::CoreGuard::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:27 + 22: tokio::runtime::scheduler::current_thread::CoreGuard::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:729:24 + 23: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:200:33 + 24: tokio::runtime::context::runtime::enter_runtime + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/runtime.rs:65:16 + 25: tokio::runtime::scheduler::current_thread::CurrentThread::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:188:9 + 26: tokio::runtime::runtime::Runtime::block_on_inner + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:368:52 + 27: tokio::runtime::runtime::Runtime::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:342:18 + 28: pkgtoolkit_funcs::package_tests::test_extract_archive + at ./tests/pkgtoolkit_funcs.rs:44:72 + 29: pkgtoolkit_funcs::package_tests::test_extract_archive::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:27:36 + 30: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 + 31: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +---- package_tests::test_package_check_missing_install stdout ---- + +thread 'package_tests::test_package_check_missing_install' (3323) panicked at src/cfg/config.rs:59:66: +called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" } +stack backtrace: + 0: __rustc::rust_begin_unwind + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:698:5 + 1: core::panicking::panic_fmt + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/panicking.rs:75:14 + 2: core::result::unwrap_failed + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1855:5 + 3: core::result::Result<T,E>::unwrap + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1226:23 + 4: mesk::cfg::config::Config::parse + at ./src/cfg/config.rs:59:66 + 5: mesk::pkgtoolkit::pkgtools::Package::extract_archive + at ./src/pkgtoolkit/pkgtools.rs:168:22 + 6: mesk::pkgtoolkit::pkgtools::Package::check + at ./src/pkgtoolkit/pkgtools.rs:306:9 + 7: pkgtoolkit_funcs::package_tests::test_package_check_missing_install::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:122:22 + 8: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 9: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:70 + 11: tokio::task::coop::with_budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:167:5 + 12: tokio::task::coop::budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:133:5 + 13: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:25 + 14: tokio::runtime::scheduler::current_thread::Context::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:432:19 + 15: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:741:44 + 16: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:68 + 17: tokio::runtime::context::scoped::Scoped<T>::set + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/scoped.rs:40:9 + 18: tokio::runtime::context::set_scheduler::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:38 + 19: std::thread::local::LocalKey<T>::try_with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:315:12 + 20: std::thread::local::LocalKey<T>::with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:279:20 + 21: tokio::runtime::context::set_scheduler + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:17 + 22: tokio::runtime::scheduler::current_thread::CoreGuard::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:27 + 23: tokio::runtime::scheduler::current_thread::CoreGuard::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:729:24 + 24: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:200:33 + 25: tokio::runtime::context::runtime::enter_runtime + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/runtime.rs:65:16 + 26: tokio::runtime::scheduler::current_thread::CurrentThread::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:188:9 + 27: tokio::runtime::runtime::Runtime::block_on_inner + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:368:52 + 28: tokio::runtime::runtime::Runtime::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:342:18 + 29: pkgtoolkit_funcs::package_tests::test_package_check_missing_install + at ./tests/pkgtoolkit_funcs.rs:124:22 + 30: pkgtoolkit_funcs::package_tests::test_package_check_missing_install::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:108:50 + 31: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 + 32: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +---- package_tests::test_package_check_valid stdout ---- + +thread 'package_tests::test_package_check_valid' (3324) panicked at src/cfg/config.rs:59:66: +called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" } +stack backtrace: + 0: __rustc::rust_begin_unwind + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:698:5 + 1: core::panicking::panic_fmt + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/panicking.rs:75:14 + 2: core::result::unwrap_failed + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1855:5 + 3: core::result::Result<T,E>::unwrap + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1226:23 + 4: mesk::cfg::config::Config::parse + at ./src/cfg/config.rs:59:66 + 5: mesk::pkgtoolkit::pkgtools::Package::extract_archive + at ./src/pkgtoolkit/pkgtools.rs:168:22 + 6: mesk::pkgtoolkit::pkgtools::Package::check + at ./src/pkgtoolkit/pkgtools.rs:306:9 + 7: pkgtoolkit_funcs::package_tests::test_package_check_valid::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:94:22 + 8: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 9: <core::pin::Pin<P> as core::future::future::Future>::poll + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/future/future.rs:133:9 + 10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:70 + 11: tokio::task::coop::with_budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:167:5 + 12: tokio::task::coop::budget + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:133:5 + 13: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:742:25 + 14: tokio::runtime::scheduler::current_thread::Context::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:432:19 + 15: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:741:44 + 16: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:68 + 17: tokio::runtime::context::scoped::Scoped<T>::set + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/scoped.rs:40:9 + 18: tokio::runtime::context::set_scheduler::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:38 + 19: std::thread::local::LocalKey<T>::try_with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:315:12 + 20: std::thread::local::LocalKey<T>::with + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/thread/local.rs:279:20 + 21: tokio::runtime::context::set_scheduler + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context.rs:176:17 + 22: tokio::runtime::scheduler::current_thread::CoreGuard::enter + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:829:27 + 23: tokio::runtime::scheduler::current_thread::CoreGuard::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:729:24 + 24: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}} + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:200:33 + 25: tokio::runtime::context::runtime::enter_runtime + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/runtime.rs:65:16 + 26: tokio::runtime::scheduler::current_thread::CurrentThread::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/current_thread/mod.rs:188:9 + 27: tokio::runtime::runtime::Runtime::block_on_inner + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:368:52 + 28: tokio::runtime::runtime::Runtime::block_on + at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:342:18 + 29: pkgtoolkit_funcs::package_tests::test_package_check_valid + at ./tests/pkgtoolkit_funcs.rs:96:22 + 30: pkgtoolkit_funcs::package_tests::test_package_check_valid::{{closure}} + at ./tests/pkgtoolkit_funcs.rs:62:40 + 31: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 + 32: core::ops::function::FnOnce::call_once + at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5 +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + + +failures: + package_tests::test_extract_archive + package_tests::test_package_check_arch_mismatch + package_tests::test_package_check_empty_install + package_tests::test_package_check_missing_install + package_tests::test_package_check_valid + +test result: FAILED. 1 passed; 5 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s + +[1m[91merror[0m: test failed, to rerun pass `--test pkgtoolkit_funcs` diff --git a/src/cfg/config.rs b/src/cfg/config.rs index 08cdbd9..750296d 100644 --- a/src/cfg/config.rs +++ b/src/cfg/config.rs @@ -1,4 +1,4 @@ -use serde::{Deserialize, Serialize}; +use serde::{de::Error as DeError, Deserialize, Serialize}; use std::fs; use toml; @@ -55,8 +55,19 @@ impl Config { /// Parse the /etc/mesk.toml file and return the Config object. /// /// This function reads the /etc/mesk.toml file, parses it and returns the Config object. + /// If the file is not available, it falls back to the `MESK_CONFIG_TOML` environment + /// variable containing the full TOML configuration. pub fn parse() -> Result<Config, toml::de::Error> { - let contents = fs::read_to_string("/etc/mesk/mesk.toml").unwrap(); + let contents = match fs::read_to_string("/etc/mesk/mesk.toml") { + Ok(c) => c, + Err(_e) => std::env::var("MESK_CONFIG_TOML").map_err(|env_err| { + DeError::custom(format!( + "Failed to read /etc/mesk/mesk.toml and MESK_CONFIG_TOML is not set: {}", + env_err + )) + })?, + }; + let result: Config = toml::from_str(&contents)?; Ok(result) } diff --git a/tests/shared.rs b/tests/shared.rs index 5df63de..d226425 100644 --- a/tests/shared.rs +++ b/tests/shared.rs @@ -19,5 +19,10 @@ pub fn create_test_config(temp_dir_path: &str) -> Config { }, }; + // Export this config as TOML so runtime code can read it via MESK_CONFIG_TOML + if let Ok(toml_str) = toml::to_string(&cfg) { + std::env::set_var("MESK_CONFIG_TOML", toml_str); + } + cfg } |
