mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-17 17:55:11 +00:00
110a1c716b
This commit removes the 'main' function present in main.rs, renames it to exa.rs, and puts the 'main' function in its own binary. This, I think, makes it more clear how the program works and where the main entry point is. Librarification also means that we can start testing as a whole. Two tests have been added that test everything, passing in raw command-line arguments then comparing against the binary coloured text that gets produced. Casualties include having to specifically mark some code blocks in documentation as 'tests', as rustdoc kept on trying to execute my ANSI art.
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
extern crate exa;
|
||
use exa::Exa;
|
||
|
||
/// ---------------------------------------------------------------------------
|
||
/// These tests assume that the ‘generate annoying testcases’ script has been
|
||
/// run first. Otherwise, they will break!
|
||
/// ---------------------------------------------------------------------------
|
||
|
||
|
||
static DIRECTORIES: &'static str = concat!(
|
||
"\x1B[1;34m", "attributes", "\x1B[0m", '\n',
|
||
"\x1B[1;34m", "links", "\x1B[0m", '\n',
|
||
"\x1B[1;34m", "passwd", "\x1B[0m", '\n',
|
||
"\x1B[1;34m", "permissions", "\x1B[0m", '\n',
|
||
);
|
||
|
||
#[test]
|
||
fn directories() {
|
||
let mut output = Vec::<u8>::new();
|
||
Exa::new( &[ "-1", "testcases" ], &mut output).unwrap().run().unwrap();
|
||
assert_eq!(output, DIRECTORIES.as_bytes());
|
||
}
|
||
|
||
|
||
static PERMISSIONS: &'static str = concat!(
|
||
"\x1B[1;32m", "all-permissions", "\x1B[0m", '\n',
|
||
"\x1B[1;34m", "forbidden-directory", "\x1B[0m", '\n',
|
||
"no-permissions", '\n',
|
||
);
|
||
|
||
#[test]
|
||
fn permissions() {
|
||
let mut output = Vec::<u8>::new();
|
||
Exa::new( &[ "-1", "testcases/permissions" ], &mut output).unwrap().run().unwrap();
|
||
assert_eq!(output, PERMISSIONS.as_bytes());
|
||
}
|