mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 07:04:04 +00:00 
			
		
		
		
	Modified snapshot tests to support tab expansion.
This changes how the files are named (to allow for snapshots that aren't directly related to the --style argument) and fixes the generate_snapshots.py script to work with the latest version of bat. Three new tests are also introduced: - tabs_4 - Tab expansion with a width of 4. - tabs_8 - Tab expansion with a width of 8. - tabs_passthrough - No tab expansion.
This commit is contained in:
		| @@ -10,16 +10,24 @@ def generate_snapshots(): | ||||
|  | ||||
|     for num in range(len(single_styles)): | ||||
|         for grouped in itertools.combinations(single_styles, num + 1): | ||||
|             generate_snapshot(",".join(grouped)) | ||||
|             generate_style_snapshot(",".join(grouped)) | ||||
|  | ||||
|     for style in collective_styles: | ||||
|         generate_snapshot(style) | ||||
|         generate_style_snapshot(style) | ||||
|  | ||||
| def generate_snapshot(option): | ||||
|     command = "../../target/debug/bat --style={0} sample.rs > output/{0}.snapshot.txt".format( | ||||
|         option | ||||
|     generate_snapshot("tabs_passthrough", "--tabs=0 --style=full") | ||||
|     generate_snapshot("tabs_4", "--tabs=4 --style=full") | ||||
|     generate_snapshot("tabs_8", "--tabs=8 --style=full") | ||||
|  | ||||
| def generate_style_snapshot(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 | ||||
|     ) | ||||
|     print("generating snapshot for {}".format(option)) | ||||
|     print("generating snapshot for {}".format(name)) | ||||
|     subprocess.call(command, shell=True) | ||||
|  | ||||
| def build_bat(): | ||||
|   | ||||
| @@ -10,7 +10,7 @@ fn main() { | ||||
|         "The perimeter of the rectangle is {} pixels.", | ||||
|         perimeter(&rect1) | ||||
|     ); | ||||
|     println!(r#"This line contains invalid utf8:  "<22><><EFBFBD><EFBFBD><EFBFBD>"#; | ||||
|     println!(r#"This line contains invalid utf8:  "<22><><EFBFBD><EFBFBD><EFBFBD>"#; | ||||
| } | ||||
|  | ||||
| fn area(rectangle: &Rectangle) -> u32 { | ||||
| @@ -20,3 +20,17 @@ fn area(rectangle: &Rectangle) -> u32 { | ||||
| fn perimeter(rectangle: &Rectangle) -> u32 { | ||||
|     (rectangle.width + rectangle.height) * 2 | ||||
| } | ||||
|  | ||||
| // Tab alignment: | ||||
| /* | ||||
| 	Indent | ||||
| 	1	2	3	4 | ||||
| 1	? | ||||
| 22	? | ||||
| 333	? | ||||
| 4444	? | ||||
| 55555	? | ||||
| 666666	? | ||||
| 7777777	? | ||||
| 88888888	? | ||||
| */ | ||||
|   | ||||
| @@ -16,3 +16,17 @@ fn main() { | ||||
| fn area(rectangle: &Rectangle) -> u32 { | ||||
|     rectangle.width * rectangle.height | ||||
| } | ||||
|  | ||||
| // Tab alignment: | ||||
| /* | ||||
| 	Indent | ||||
| 	1	2	3	4 | ||||
| 1	? | ||||
| 22	? | ||||
| 333	? | ||||
| 4444	? | ||||
| 55555	? | ||||
| 666666	? | ||||
| 7777777	? | ||||
| 88888888	? | ||||
| */ | ||||
		Reference in New Issue
	
	Block a user