summaryrefslogtreecommitdiffstats
path: root/tests/snapshots
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2018-09-12 20:28:42 +0200
committersharkdp <davidpeter@web.de>2018-09-12 20:28:42 +0200
commitb4c6e412dc01e6e2e794436ede4b953b7e26d981 (patch)
treee95e0dc6b9c39b49a0f63fd7edb89c70ef435fed /tests/snapshots
parent3e21d69a92a1a3bb388d75c22f3f62c41cd558cb (diff)
Make generate_snapshots script more robust
Diffstat (limited to 'tests/snapshots')
-rwxr-xr-xtests/snapshots/generate_snapshots.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/snapshots/generate_snapshots.py b/tests/snapshots/generate_snapshots.py
index 7a4798ff..fcbfdba9 100755
--- a/tests/snapshots/generate_snapshots.py
+++ b/tests/snapshots/generate_snapshots.py
@@ -1,9 +1,11 @@
#!/usr/bin/env python3
+
import itertools
import subprocess
import pathlib
import shutil
+
def generate_snapshots():
single_styles = ["changes", "grid", "header", "numbers"]
collective_styles = ["full", "plain"]
@@ -22,33 +24,41 @@ def generate_snapshots():
generate_snapshot("tabs_8", "--tabs=8 --style=full --wrap=never")
generate_snapshot("tabs_8_wrapped", "--tabs=8 --style=full --wrap=character")
+
def generate_style_snapshot(style):
- generate_snapshot(style.replace(",","_"), "--style={}".format(style))
+ generate_snapshot(style.replace(",", "_"), "--style={}".format(style))
+
def generate_snapshot(name, arguments):
- command = "../../target/debug/bat --decorations=always {1} sample.rs > output/{0}.snapshot.txt".format(
- name,
- arguments
+ command = "cargo run -- --paging=never --color=never --decorations=always "
+ command += "{args} sample.rs > output/{name}.snapshot.txt".format(
+ name=name,
+ args=arguments
)
print("generating snapshot for {}".format(name))
subprocess.call(command, shell=True)
+
def build_bat():
print("building bat")
subprocess.call("cargo build", cwd="../..", shell=True)
+
def prepare_output_dir():
shutil.rmtree("output", ignore_errors=True)
pathlib.Path("output").mkdir()
+
def modify_sample_file():
print("modifying sample.rs to show changes")
shutil.copyfile("sample.modified.rs", "sample.rs")
+
def undo_sample_file_modification():
print("undoing sample.rs modifications")
subprocess.call("git checkout -- sample.rs", shell=True)
+
build_bat()
prepare_output_dir()
modify_sample_file()