Hi I was just preparing to update the AUR package to 0.4.0. Part of the build process runs the tests via cargo test, which is failing. I tried a separate git checkout of the 0.4.0 tag and cargo test worked. I then tried downloading the release tarball and building that by hand and it raises the error.
System Info
Arch Linux x86_64
cargo 1.26.0 (0e7c5a931 2018-04-06)
rustc 1.26.1 (827013a31 2018-05-25)
Steps to Reproduce
cd bat-0.4.0cargo testError
running 4 tests
test terminal::test_rgb2ansi_approx ... ok
test terminal::test_rgb2ansi_black_white ... ok
test terminal::test_rgb2ansi_color ... ok
test terminal::test_rgb2ansi_gray ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/tester-63a4992aa7642b30
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/tests-b1eaff77269a838f
running 1 test
thread panicked while panicking. aborting.
error: process didn't exit successfully: `/home/wmoore/Downloads/bat-0.4.0/target/debug/deps/tests-b1eaff77269a838f` (signal: 4, SIGILL: illegal instruction)
Thank you for reporting this. I can reproduce this. Not sure what is going on (currently investigating).
Ok, this is due to the way we reset the sample.rs file after running the tests. It expects the current folder to be a Git repository:
fn undo_sample_file_modification() {
let output = Command::new("git")
.args(&["checkout", "--", "tests/snapshots/sample.rs"])
.output()
.expect("git checkout failed");
if !output.status.success() {
panic!("undoing modified sample changes failed")
}
}
This should be fixed via v0.4.1. Thanks!
Still getting the same error on 0.4.1. I've confirmed that the changes in 86c1777 are present, so not sure what's going on.
I can not reproduce this. Could you please try to run
cargo test -- --nocapture
and send the output?
I think I know why it's failing. Each AUR package is a git repo. When building a package the directory structure looks like this:
.
├── bat-0.4.1.tar.gz
├── PKGBUILD
└── src
├── bat-0.4.1
The bat-0.4.1 directory contains the extracted bat-0.4.1.tar.gz file. When building and testing the PKGBUILD script cds into this directory.
So the snapshot test tries to run because it is in a git repo, just it's not the bat git repo, it's this one: https://aur.archlinux.org/bat.git since none of the bat source is tracked the tests fail... at least that's my theory.
I'm going to update the package but I suppose it would be nice to be able to set end environment variable to skip the snapshot tests, even when in a git repo.
Here is the output:
cargo test --release -- --nocapture
Finished release [optimized] target(s) in 0.0 secs
Running target/release/deps/bat-5d1519c3fb280f62
running 4 tests
test terminal::test_rgb2ansi_approx ... ok
test terminal::test_rgb2ansi_black_white ... ok
test terminal::test_rgb2ansi_color ... ok
test terminal::test_rgb2ansi_gray ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/release/deps/tester-07a788784bad2105
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/release/deps/tests-dc62080fd2d13e4e
running 1 test
testing changes
thread 'test_snapshots' panicked at 'assertion failed: `(left == right)`
left: `" struct Rectangle {\n width: u32,\n height: u32,\n }\n \n_ fn main() {\n let rect1 = Rectangle { width: 30, height: 50 };\n \n println!(\n~ \"The perimeter of the rectangle is {} pixels.\",\n~ perimeter(&rect1)\n );\n+ println!(r#\"This line contains invalid utf8: \"�����\"#;\n }\n \n fn area(rectangle: &Rectangle) -> u32 {\n rectangle.width * rectangle.height\n }\n+ \n+ fn perimeter(rectangle: &Rectangle) -> u32 {\n+ (rectangle.width + rectangle.height) * 2\n+ }\n"`,
right: `" struct Rectangle {\n width: u32,\n height: u32,\n }\n \n fn main() {\n let rect1 = Rectangle { width: 30, height: 50 };\n \n println!(\n \"The perimeter of the rectangle is {} pixels.\",\n perimeter(&rect1)\n );\n println!(r#\"This line contains invalid utf8: \"�����\"#;\n }\n \n fn area(rectangle: &Rectangle) -> u32 {\n rectangle.width * rectangle.height\n }\n \n fn perimeter(rectangle: &Rectangle) -> u32 {\n (rectangle.width + rectangle.height) * 2\n }\n"`', tests/tester.rs:46:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'test_snapshots' panicked at 'undoing modified sample changes failed', tests/tester.rs:70:9
stack backtrace:
0: 0x5582f2b26ecb - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::hc94fccaa2a711028
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: 0x5582f2b2dbb0 - std::sys_common::backtrace::print::h8c9041d44f9f1a2c
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: 0x5582f2b2132d - std::panicking::default_hook::{{closure}}::ha2f043e73975ac4b
at libstd/panicking.rs:207
3: 0x5582f2b2108b - std::panicking::default_hook::h1db43126ea6aa931
at libstd/panicking.rs:223
4: 0x5582f2b2177f - std::panicking::rust_panic_with_hook::h4de9fd85b55cffd7
at libstd/panicking.rs:402
5: 0x5582f2aceb05 - std::panicking::begin_panic::hb320af60e861ede6
6: 0x5582f2ad0bda - <tests::tester::BatTester as core::ops::drop::Drop>::drop::h9ffd20ddec868816
7: 0x5582f2ad10eb - core::ptr::drop_in_place::h17fb875b68c7e6a9
8: 0x5582f2ad17ae - tests::test_snapshots::h00c956177cd79189
9: 0x5582f2ace798 - core::ops::function::FnOnce::call_once::h9788b70bf15bf9fe
10: 0x5582f2ad3841 - <F as alloc::boxed::FnBox<A>>::call_box::h0473d9772dfab55b
at libtest/lib.rs:1453
at /checkout/src/libcore/ops/function.rs:223
at /checkout/src/liballoc/boxed.rs:784
11: 0x5582f2b34d0e - __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
12: 0x5582f2ae648a - std::sys_common::backtrace::__rust_begin_short_backtrace::hff89934d17e5503a
at /checkout/src/libstd/panicking.rs:285
at /checkout/src/libstd/panic.rs:361
at libtest/lib.rs:1408
at /checkout/src/libstd/sys_common/backtrace.rs:136
13: 0x5582f2ae2492 - std::panicking::try::do_call::h85c01c3393c72433
at /checkout/src/libstd/thread/mod.rs:406
at /checkout/src/libstd/panic.rs:296
at /checkout/src/libstd/panicking.rs:306
14: 0x5582f2b34d0e - __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
15: 0x5582f2af72f3 - <F as alloc::boxed::FnBox<A>>::call_box::h5d3797e11b36466f
at /checkout/src/libstd/panicking.rs:285
at /checkout/src/libstd/panic.rs:361
at /checkout/src/libstd/thread/mod.rs:405
at /checkout/src/liballoc/boxed.rs:784
16: 0x5582f2b29e37 - std::sys_common::thread::start_thread::hbdb0265288bf7dcc
at /checkout/src/liballoc/boxed.rs:794
at libstd/sys_common/thread.rs:24
17: 0x5582f2b17d68 - std::sys::unix::thread::Thread::new::thread_start::h99a7fe00c40fd1be
at libstd/sys/unix/thread.rs:90
18: 0x7f61987da074 - start_thread
19: 0x7f61982f753e - clone
20: 0x0 - <unknown>
thread panicked while panicking. aborting.
error: process didn't exit successfully: `/home/wmoore/Projects/aur-bat/src/bat-0.4.1/target/release/deps/tests-dc62080fd2d13e4e --nocapture` (signal: 4, SIGILL: illegal instruction)
@wezm Excellent observation. I have opened #165 in an attempt to solve this in a more future-proof way by creating a completely new Git repository in a temporary directory.
Fixed in bat 0.5.