1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-01 10:52:24 +01:00

Merge remote-tracking branch 'origin/master' into fix-1063

This commit is contained in:
Martin Nordholts
2021-01-10 11:56:03 +01:00
22 changed files with 323 additions and 106 deletions

View File

@@ -8,7 +8,7 @@ fn all_themes_are_present() {
let assets = HighlightingAssets::from_binary();
let mut themes: Vec<_> = assets.themes().collect();
themes.sort();
themes.sort_unstable();
assert_eq!(
themes,

View File

@@ -7,7 +7,7 @@ macro_rules! snapshot_tests {
$(
#[test]
fn $test_name() {
let bat_tester = BatTester::new();
let bat_tester = BatTester::default();
bat_tester.test_snapshot(stringify!($test_name), $style);
}
)*

View File

@@ -0,0 +1,19 @@
set terminal pngcairo enhanced
set output "/tmp/polynomial.png"
set grid
set xrange [-5:5]
set yrange [-5:10]
set samples 10000
set key bottom right
f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5
plot \
 f(x) title "polynomial of degree 4" \
 with lines \
 linewidth 2 \
 linetype rgb '#0077ff'

View File

@@ -0,0 +1,19 @@
set terminal pngcairo enhanced
set output "/tmp/polynomial.png"
set grid
set xrange [-5:5]
set yrange [-5:10]
set samples 10000
set key bottom right
f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5
plot \
f(x) title "polynomial of degree 4" \
with lines \
linewidth 2 \
linetype rgb '#0077ff'

View File

@@ -19,23 +19,6 @@ pub struct BatTester {
}
impl BatTester {
pub fn new() -> Self {
let temp_dir = create_sample_directory().expect("sample directory");
let root = env::current_exe()
.expect("tests executable")
.parent()
.expect("tests executable directory")
.parent()
.expect("bat executable directory")
.to_path_buf();
let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" };
let exe = root.join(exe_name);
BatTester { temp_dir, exe }
}
pub fn test_snapshot(&self, name: &str, style: &str) {
let output = Command::new(&self.exe)
.current_dir(self.temp_dir.path())
@@ -66,6 +49,25 @@ impl BatTester {
}
}
impl Default for BatTester {
fn default() -> Self {
let temp_dir = create_sample_directory().expect("sample directory");
let root = env::current_exe()
.expect("tests executable")
.parent()
.expect("tests executable directory")
.parent()
.expect("bat executable directory")
.to_path_buf();
let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" };
let exe = root.join(exe_name);
BatTester { temp_dir, exe }
}
}
fn create_sample_directory() -> Result<TempDir, git2::Error> {
// Create temp directory and initialize repository
let temp_dir = TempDir::new("bat-tests").expect("Temp directory");