2018-05-12 14:23:05 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-05-12 14:23:05 +00:00
|
|
|
import itertools
|
|
|
|
import subprocess
|
|
|
|
import pathlib
|
|
|
|
import shutil
|
|
|
|
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-05-12 14:23:05 +00:00
|
|
|
def generate_snapshots():
|
|
|
|
single_styles = ["changes", "grid", "header", "numbers"]
|
|
|
|
collective_styles = ["full", "plain"]
|
|
|
|
|
|
|
|
for num in range(len(single_styles)):
|
|
|
|
for grouped in itertools.combinations(single_styles, num + 1):
|
2018-09-11 02:19:43 +00:00
|
|
|
generate_style_snapshot(",".join(grouped))
|
2018-05-12 14:23:05 +00:00
|
|
|
|
|
|
|
for style in collective_styles:
|
2018-09-11 02:19:43 +00:00
|
|
|
generate_style_snapshot(style)
|
2018-05-12 14:23:05 +00:00
|
|
|
|
2018-09-11 20:47:01 +00:00
|
|
|
generate_snapshot("tabs_passthrough", "--tabs=0 --style=full --wrap=never")
|
|
|
|
generate_snapshot("tabs_passthrough_wrapped", "--tabs=0 --style=full --wrap=character")
|
|
|
|
generate_snapshot("tabs_4", "--tabs=4 --style=full --wrap=never")
|
|
|
|
generate_snapshot("tabs_4_wrapped", "--tabs=4 --style=full --wrap=character")
|
|
|
|
generate_snapshot("tabs_8", "--tabs=8 --style=full --wrap=never")
|
|
|
|
generate_snapshot("tabs_8_wrapped", "--tabs=8 --style=full --wrap=character")
|
2018-09-11 02:19:43 +00:00
|
|
|
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-09-11 02:19:43 +00:00
|
|
|
def generate_style_snapshot(style):
|
2018-09-12 18:28:42 +00:00
|
|
|
generate_snapshot(style.replace(",", "_"), "--style={}".format(style))
|
|
|
|
|
2018-09-11 02:19:43 +00:00
|
|
|
|
|
|
|
def generate_snapshot(name, arguments):
|
2018-09-12 18:28:42 +00:00
|
|
|
command = "cargo run -- --paging=never --color=never --decorations=always "
|
|
|
|
command += "{args} sample.rs > output/{name}.snapshot.txt".format(
|
|
|
|
name=name,
|
|
|
|
args=arguments
|
2018-05-12 14:23:05 +00:00
|
|
|
)
|
2018-09-11 02:19:43 +00:00
|
|
|
print("generating snapshot for {}".format(name))
|
2018-05-12 14:23:05 +00:00
|
|
|
subprocess.call(command, shell=True)
|
|
|
|
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-05-24 10:06:02 +00:00
|
|
|
def build_bat():
|
|
|
|
print("building bat")
|
|
|
|
subprocess.call("cargo build", cwd="../..", shell=True)
|
|
|
|
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-05-12 14:23:05 +00:00
|
|
|
def prepare_output_dir():
|
|
|
|
shutil.rmtree("output", ignore_errors=True)
|
|
|
|
pathlib.Path("output").mkdir()
|
|
|
|
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-05-12 14:23:05 +00:00
|
|
|
def modify_sample_file():
|
|
|
|
print("modifying sample.rs to show changes")
|
|
|
|
shutil.copyfile("sample.modified.rs", "sample.rs")
|
|
|
|
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-05-12 14:23:05 +00:00
|
|
|
def undo_sample_file_modification():
|
|
|
|
print("undoing sample.rs modifications")
|
|
|
|
subprocess.call("git checkout -- sample.rs", shell=True)
|
|
|
|
|
2018-09-12 18:28:42 +00:00
|
|
|
|
2018-05-24 10:06:02 +00:00
|
|
|
build_bat()
|
2018-05-12 14:23:05 +00:00
|
|
|
prepare_output_dir()
|
|
|
|
modify_sample_file()
|
|
|
|
generate_snapshots()
|
|
|
|
undo_sample_file_modification()
|