on master help sign in
Make generate_snapshots script more robust
commitb4c6e412dc01e6e2e794436ede4b953b7e26d981 authorsharkdp <davidpeter@web.de> dateWed 12 Sep 2018, 20:28 (8 years ago) parent3e21d69
1 file changed+14−4
tests/snapshots/generate_snapshots.py+14−4
tests/snapshots/generate_snapshots.py+14−4
@@ -1,9 +1,11 @@
11#!/usr/bin/env python3
2+
23import itertools
34import subprocess
45import pathlib
56import shutil
67
8+
79def generate_snapshots():
810 single_styles = ["changes", "grid", "header", "numbers"]
911 collective_styles = ["full", "plain"]
@@ -22,33 +24,41 @@ def generate_snapshots():
2224 generate_snapshot("tabs_8", "--tabs=8 --style=full --wrap=never")
2325 generate_snapshot("tabs_8_wrapped", "--tabs=8 --style=full --wrap=character")
2426
27+
2528def generate_style_snapshot(style):
26− generate_snapshot(style.replace(",","_"), "--style={}".format(style))
29+ generate_snapshot(style.replace(",", "_"), "--style={}".format(style))
30+
2731
2832def generate_snapshot(name, arguments):
29− command = "../../target/debug/bat --decorations=always {1} sample.rs > output/{0}.snapshot.txt".format(
30− name,
31− arguments
33+ command = "cargo run -- --paging=never --color=never --decorations=always "
34+ command += "{args} sample.rs > output/{name}.snapshot.txt".format(
35+ name=name,
36+ args=arguments
3237 )
3338 print("generating snapshot for {}".format(name))
3439 subprocess.call(command, shell=True)
3540
41+
3642def build_bat():
3743 print("building bat")
3844 subprocess.call("cargo build", cwd="../..", shell=True)
3945
46+
4047def prepare_output_dir():
4148 shutil.rmtree("output", ignore_errors=True)
4249 pathlib.Path("output").mkdir()
4350
51+
4452def modify_sample_file():
4553 print("modifying sample.rs to show changes")
4654 shutil.copyfile("sample.modified.rs", "sample.rs")
4755
56+
4857def undo_sample_file_modification():
4958 print("undoing sample.rs modifications")
5059 subprocess.call("git checkout -- sample.rs", shell=True)
5160
61+
5262build_bat()
5363prepare_output_dir()
5464modify_sample_file()