chmln / handlr

A better xdg-utils
MIT License
607 stars 24 forks source link

Tests fail and the ci does not run cargo check #35

Closed mweinelt closed 3 years ago

mweinelt commented 3 years ago

Running the tests during package update I noticed they fail like this. I also noticed that you don't run cargo check during your CI. Why is that?

running 5 tests
test common::desktop_entry::tests::complex_exec ... ok
test apps::user::tests::wildcard_mimes ... ok
test common::mime_types::tests::from_ext ... FAILED
test common::mime_types::tests::user_input ... FAILED
test common::mime_types::tests::from_path ... FAILED

failures:

---- common::mime_types::tests::from_ext stdout ----
Error: Ambiguous(".mp3")
thread 'common::mime_types::tests::from_ext' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rustc-1.51.0-src/library/test/src/lib.rs:194:5
stack backtrace:
   0:     0x55555565230c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc72b2a79902e20a2
   1:     0x55555567ac7f - core::fmt::write::h363ea858f8d20109
   2:     0x55555563ec06 - std::io::Write::write_fmt::hb816cf7056dd43f9
   3:     0x555555639ad5 - std::panicking::default_hook::{{closure}}::hf776c4b8a29e2c23
   4:     0x5555556396e3 - std::panicking::default_hook::hd9a17e7e9b9c0d25
   5:     0x55555563a105 - std::panicking::rust_panic_with_hook::hf65e38fdef13d248
   6:     0x555555652b27 - std::panicking::begin_panic_handler::{{closure}}::h469be7df0b5aefa3
   7:     0x55555565246c - std::sys_common::backtrace::__rust_end_short_backtrace::hc9b4220705693734
   8:     0x555555639cb2 - rust_begin_unwind
   9:     0x55555567aa21 - core::panicking::panic_fmt::h0c4f421549c9e9f1
  10:     0x5555555a61bc - test::assert_test_result::h4083b2423d23db49
  11:     0x5555555a2f2d - core::ops::function::FnOnce::call_once::hf167e30cd78856b0
  12:     0x5555555fa5f3 - test::__rust_begin_short_backtrace::he4531e9de3270570
  13:     0x5555555f92a0 - test::run_test::run_test_inner::{{closure}}::h287fb0194f6b5030
  14:     0x5555555f1636 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf6f5301e66e2e3b8
  15:     0x5555556038cd - core::ops::function::FnOnce::call_once{{vtable.shim}}::ha84e9c86101a5ab7
  16:     0x555555641e98 - std::sys::unix::thread::Thread::new::thread_start::h13c6b74cf3ad27b3
  17:     0x7ffff7f99e9e - start_thread
  18:     0x7ffff7d8349f - __GI___clone
  19:                0x0 - <unknown>

---- common::mime_types::tests::user_input stdout ----
Error: Ambiguous(".pdf")
thread 'common::mime_types::tests::user_input' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rustc-1.51.0-src/library/test/src/lib.rs:194:5
stack backtrace:
   0:     0x55555565230c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc72b2a79902e20a2
   1:     0x55555567ac7f - core::fmt::write::h363ea858f8d20109
   2:     0x55555563ec06 - std::io::Write::write_fmt::hb816cf7056dd43f9
   3:     0x555555639ad5 - std::panicking::default_hook::{{closure}}::hf776c4b8a29e2c23
   4:     0x5555556396e3 - std::panicking::default_hook::hd9a17e7e9b9c0d25
   5:     0x55555563a105 - std::panicking::rust_panic_with_hook::hf65e38fdef13d248
   6:     0x555555652b27 - std::panicking::begin_panic_handler::{{closure}}::h469be7df0b5aefa3
   7:     0x55555565246c - std::sys_common::backtrace::__rust_end_short_backtrace::hc9b4220705693734
   8:     0x555555639cb2 - rust_begin_unwind
   9:     0x55555567aa21 - core::panicking::panic_fmt::h0c4f421549c9e9f1
  10:     0x5555555a61bc - test::assert_test_result::h4083b2423d23db49
  11:     0x5555555a2ebd - core::ops::function::FnOnce::call_once::h30c031ecba034140
  12:     0x5555555fa5f3 - test::__rust_begin_short_backtrace::he4531e9de3270570
  13:     0x5555555f92a0 - test::run_test::run_test_inner::{{closure}}::h287fb0194f6b5030
  14:     0x5555555f1636 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf6f5301e66e2e3b8
  15:     0x5555556038cd - core::ops::function::FnOnce::call_once{{vtable.shim}}::ha84e9c86101a5ab7
  16:     0x555555641e98 - std::sys::unix::thread::Thread::new::thread_start::h13c6b74cf3ad27b3
  17:     0x7ffff7f99e9e - start_thread
  18:     0x7ffff7d8349f - __GI___clone
  19:                0x0 - <unknown>

---- common::mime_types::tests::from_path stdout ----
thread 'common::mime_types::tests::from_path' panicked at 'assertion failed: `(left == right)`
  left: `"application/x-zerosize"`,
 right: `"text/plain"`', src/common/mime_types.rs:108:9
stack backtrace:
   0:     0x55555565230c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc72b2a79902e20a2
   1:     0x55555567ac7f - core::fmt::write::h363ea858f8d20109
   2:     0x55555563ec06 - std::io::Write::write_fmt::hb816cf7056dd43f9
   3:     0x555555639ad5 - std::panicking::default_hook::{{closure}}::hf776c4b8a29e2c23
   4:     0x5555556396e3 - std::panicking::default_hook::hd9a17e7e9b9c0d25
   5:     0x55555563a105 - std::panicking::rust_panic_with_hook::hf65e38fdef13d248
   6:     0x555555652b27 - std::panicking::begin_panic_handler::{{closure}}::h469be7df0b5aefa3
   7:     0x55555565246c - std::sys_common::backtrace::__rust_end_short_backtrace::hc9b4220705693734
   8:     0x555555639cb2 - rust_begin_unwind
   9:     0x55555567aa21 - core::panicking::panic_fmt::h0c4f421549c9e9f1
  10:     0x55555559303b - handlr::common::mime_types::tests::from_path::hbe545f74907d82a9
  11:     0x5555555a2f55 - core::ops::function::FnOnce::call_once::hf1a4d36b1021ffd8
  12:     0x5555555fa5f3 - test::__rust_begin_short_backtrace::he4531e9de3270570
  13:     0x5555555f92a0 - test::run_test::run_test_inner::{{closure}}::h287fb0194f6b5030
  14:     0x5555555f1636 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf6f5301e66e2e3b8
  15:     0x5555556038cd - core::ops::function::FnOnce::call_once{{vtable.shim}}::ha84e9c86101a5ab7
  16:     0x555555641e98 - std::sys::unix::thread::Thread::new::thread_start::h13c6b74cf3ad27b3
  17:     0x7ffff7f99e9e - start_thread
  18:     0x7ffff7d8349f - __GI___clone
  19:                0x0 - <unknown>

failures:
    common::mime_types::tests::from_ext
    common::mime_types::tests::from_path
    common::mime_types::tests::user_input

test result: FAILED. 2 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--bin handlr'
chmln commented 3 years ago

@mweinelt Hey thanks for letting me know!

Something must be off because tests are passing for me locally. Will look into this. image

mweinelt commented 3 years ago

We are running this in a sandboxed environment, so it could be related to that.

chmln commented 3 years ago

@mweinelt I suspect it could be due to missing/bare mime db as handlr relies on shared mime info.

If you're running this in a Docker container, feel free to share the image you're using and I'll try debugging that.

mweinelt commented 3 years ago

It is a nix package, so you'd need nix to test this yourself.

https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/handlr/default.nix

The maintainer disabled the tests for this reason. The sandbox only has a barebones standard environment and the locked cargo dependencies.

I could imagine your tests rely on something like shared-mime-info, I'm giving this a shot.

mweinelt commented 3 years ago

And indeed, two more tests work after adding shared-mime-info during testing. So I kinda expect handlr needs that database at runtime as well?

running 5 tests
test common::desktop_entry::tests::complex_exec ... ok
test apps::user::tests::wildcard_mimes ... FAILED
test common::mime_types::tests::user_input ... ok
test common::mime_types::tests::from_ext ... ok
test common::mime_types::tests::from_path ... ok

failures:

---- apps::user::tests::wildcard_mimes stdout ----
thread 'apps::user::tests::wildcard_mimes' panicked at 'called `Result::unwrap()` on an `Err` value: DirectoryCreationFailed(Os { code: 13, kind: PermissionDenied, message: "Permission denied" })', src/config.rs:28:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    apps::user::tests::wildcard_mimes

test result: FAILED. 4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

error: test failed, to rerun pass '--bin handlr'

Fixed, after I set an appropriate $HOME environment variable.

chmln commented 3 years ago

@mweinelt

So I kinda expect handlr needs that database at runtime as well?

Yes definitely

mweinelt commented 3 years ago

Thanks, that made everything work.

I wonder, what prevents you from running cargo test as a CI step though?

chmln commented 3 years ago

@mweinelt I've already added testing in https://github.com/chmln/handlr/commit/e8d014c113dc3e571150543bc934b56c29bf4407 soon after you opened the issue :)

mweinelt commented 3 years ago

Thank for the support, I consider this issue resolved.