on master help sign in
Updated creation script and README to match generation script
commit6c68198d19f833abf283c812f0f268a31e5b7329 authorLogan Saso <logansaso+tech@gmail.com> dateSat 10 Oct 2020, 12:24 (6 years ago) parentf3c760c
2 files changed+14−13
tests/syntax-tests/create_highlighted_versions.py+10−11 tests/syntax-tests/source/Plaintext/README.md+4−2
tests/syntax-tests/create_highlighted_versions.py+10−11
@@ -23,9 +23,14 @@ SKIP_FILENAMES = [
2323]
2424
2525
26−def get_extra_options(source):
27− with open(path.join(source, "bat_options"), "r") as f:
28− return list(map(lambda x: x.rstrip(), f.readlines()))
26+def get_options(source):
27+ source_dirpath = path.dirname(source)
28+ options = BAT_OPTIONS.copy()
29+ if path.exists(path.join(source_dirpath, "bat_options")):
30+ with open(path.join(source, "bat_options"), "r") as f:
31+ options += list(map(lambda x: x.rstrip(), f.readlines()))
32+ return options
33+
2934
3035
3136def create_highlighted_versions(output_basepath):
@@ -42,20 +47,14 @@ def create_highlighted_versions(output_basepath):
4247 env.pop("BAT_TABS", None)
4348 env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
4449
45− source_dirpath = path.dirname(source)
46− source_dirname = path.basename(source_dirpath)
50+ source_dirname = path.basename(path.dirname(source))
4751 source_filename = path.basename(source)
4852
4953 if source_filename in SKIP_FILENAMES:
5054 continue
5155
52− options = BAT_OPTIONS.copy()
53− # If a directory is empty, `files` could possibly be 0-length
54− if path.exists(path.join(source_dirpath, "bat_options")):
55− options += get_extra_options(source_dirpath)
56−
5756 bat_output = subprocess.check_output(
58− ["bat"] + options + [source],
57+ ["bat"] + get_options(source) + [source],
5958 stderr=subprocess.PIPE, env=env,
6059 )
6160
tests/syntax-tests/source/Plaintext/README.md+4−2
@@ -1,10 +1,12 @@
1−This text file was generated with the following script. Certain invalid characters were removed manually:
1+This text file was generated with the following script.
22
33```python
44with open("plaintext.txt", "w"):
5− for i in range(0x10FFFF):
5+ for i in range(176):
66 try:
77 f.write(chr(i) + "\n")
88 except:
99 pass
10+ f.write("\n")
11+ f.write("Here is a line with multiple characters")
1012```