44import subprocess
55import pathlib
66import shutil
7+ from typing import Iterable
78
89
910def generate_snapshots ():
@@ -19,22 +20,23 @@ def generate_snapshots():
1920
2021
2122def generate_style_snapshot (style ):
22- generate_snapshot (style .replace ("," , "_" ), "--style={}" .format (style ))
23+ generate_snapshot (style .replace ("," , "_" ), [ "--style={}" .format (style )] )
2324
2425
25- def generate_snapshot (name , arguments ):
26- command = "cargo run -- --paging=never --color=never --decorations=always "
27- command += "{args} sample.rs > output/{name}.snapshot.txt" . format (
28- name = name ,
29- args = arguments
30- )
26+ def generate_snapshot (name : str , arguments : Iterable [ str ] ):
27+ output_file = "output/{name}.snapshot.txt" . format ( name = name )
28+ command = [
29+ "cargo" , "run" , "--" , "--paging=never" , "--color=never" ,
30+ "--decorations=always" , * arguments , "sample.rs"
31+ ]
3132 print ("generating snapshot for {}" .format (name ))
32- subprocess .call (command , shell = True )
33+ with open (output_file , "w" ) as f :
34+ subprocess .call (command , stdout = f )
3335
3436
3537def build_bat ():
3638 print ("building bat" )
37- subprocess .call ("cargo build" , cwd = "../.." , shell = True )
39+ subprocess .call ([ "cargo" , " build"] , cwd = "../.." )
3840
3941
4042def prepare_output_dir ():
@@ -49,7 +51,7 @@ def modify_sample_file():
4951
5052def undo_sample_file_modification ():
5153 print ("undoing sample.rs modifications" )
52- subprocess .call ("git checkout -- sample.rs" , shell = True )
54+ subprocess .call ([ "git" , " checkout" , "--" , " sample.rs"] )
5355
5456
5557build_bat ()
0 commit comments