diff options
author | sharkdp <davidpeter@web.de> | 2020-08-03 13:34:21 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-08-03 15:59:53 +0200 |
commit | 02a89d8ee82865f50015ec19e675ba81b61d0960 (patch) | |
tree | 9de887b0f73aea992c9d87318444becf1a71cac6 /tests | |
parent | a70efae79b99e0c4b772d9bba43f25992d1940dc (diff) |
Add comparison script
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/syntax-tests/compare_highlighted_versions.py | 65 | ||||
-rwxr-xr-x[-rw-r--r--] | tests/syntax-tests/create_highlighted_versions.py | 5 | ||||
-rw-r--r-- | tests/syntax-tests/highlighted/Rust/test.rs | 161 | ||||
-rw-r--r-- | tests/syntax-tests/regression_test.sh | 15 |
4 files changed, 82 insertions, 164 deletions
diff --git a/tests/syntax-tests/compare_highlighted_versions.py b/tests/syntax-tests/compare_highlighted_versions.py new file mode 100755 index 00000000..9cf67e46 --- /dev/null +++ b/tests/syntax-tests/compare_highlighted_versions.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import glob +import sys +import os.path as path +import difflib +import argparse + + +def compare_highlighted_versions(root_old, root_new): + print("Comparing the following directories:") + print(" -", root_old) + print(" -", root_new) + has_changes = False + for path_old in glob.glob(path.join(root_old, "*", "*")): + filename = path.basename(path_old) + dirname = path.basename(path.dirname(path_old)) + + path_new = path.join(root_new, dirname, filename) + + print("\n========== {}/{}".format(dirname, filename)) + + with open(path_old) as file_old: + lines_old = file_old.readlines() + + with open(path_new) as file_new: + lines_new = file_new.readlines() + + diff = difflib.unified_diff( + lines_old, lines_new, fromfile=path_old, tofile=path_new + ) + + file_has_changes = False + for line in diff: + print(line, end="") + file_has_changes = True + + if file_has_changes: + has_changes = True + else: + print("No changes") + print() + + return has_changes + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="This script compares two directories that were created " + "by 'create_highlighted_versions.py'." + ) + parser.add_argument( + "OLD", help="Path to the old (stored) version of the highlighted output", + ) + parser.add_argument( + "NEW", help="Path to the new version of the highlighted output", + ) + + args = parser.parse_args() + + if compare_highlighted_versions(args.OLD, args.NEW): + print("Error: files with changes have been found") + sys.exit(1) + else: + print("Directories are the same") diff --git a/tests/syntax-tests/create_highlighted_versions.py b/tests/syntax-tests/create_highlighted_versions.py index db829733..0b04d1aa 100644..100755 --- a/tests/syntax-tests/create_highlighted_versions.py +++ b/tests/syntax-tests/create_highlighted_versions.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import subprocess import glob @@ -37,8 +37,7 @@ def create_highlighted_versions(output_basepath): with open(output_path, "wb") as output_file: output_file.write(bat_output) - relative_path = path.relpath(output_path, root) - print("Created '{}'".format(relative_path)) + print("Created '{}'".format(output_path)) except subprocess.CalledProcessError as err: print( "=== Error: Could not highlight source file '{}".format(source), diff --git a/tests/syntax-tests/highlighted/Rust/test.rs b/tests/syntax-tests/highlighted/Rust/test.rs deleted file mode 100644 index 14755cf6..00000000 --- a/tests/syntax-tests/highlighted/Rust/test.rs +++ /dev/null @@ -1,161 +0,0 @@ -[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;248;248;242mstd[0m[38;2;248;248;242m::[0m[38;2;248;248;242mio[0m[38;2;248;248;242m::[0m[38;2;248;248;242m{[0m[38;2;255;255;255mself[0m[38;2;248;248;242m,[0m[38;2;248;248;242m Write[0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;248;248;242mstd[0m[38;2;248;248;242m::[0m[38;2;248;248;242mprocess[0m[38;2;248;248;242m::[0m[38;2;248;248;242mChild[0m[38;2;248;248;242m;[0m - -[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;249;38;114mcrate[0m[38;2;248;248;242m::[0m[38;2;248;248;242merror[0m[38;2;248;248;242m::[0m[38;2;249;38;114m*[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;249;38;114mcrate[0m[38;2;248;248;242m::[0m[38;2;248;248;242mless[0m[38;2;248;248;242m::[0m[38;2;248;248;242mretrieve_less_version[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;249;38;114mcrate[0m[38;2;248;248;242m::[0m[38;2;248;248;242mpaging[0m[38;2;248;248;242m::[0m[38;2;248;248;242mPagingMode[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mderive[0m[38;2;248;248;242m([0m[38;2;248;248;242mDebug[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;249;38;114mpub[0m[38;2;248;248;242m [0m[3;38;2;102;217;239menum[0m[38;2;248;248;242m [0m[38;2;166;226;46mOutputType[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;248;248;242m Pager[0m[38;2;248;248;242m([0m[38;2;248;248;242mChild[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m Stdout[0m[38;2;248;248;242m([0m[38;2;248;248;242mio[0m[38;2;248;248;242m::[0m[38;2;248;248;242mStdout[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m}[0m - -[3;38;2;102;217;239mimpl[0m[38;2;248;248;242m [0m[38;2;166;226;46mOutputType[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;248;248;242m [0m[38;2;249;38;114mpub[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mfrom_mode[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mmode[0m[38;2;248;248;242m:[0m[38;2;248;248;242m PagingMode, [0m[3;38;2;253;151;31mpager[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mOption[0m[38;2;248;248;242m<[0m[38;2;249;38;114m&[0m[3;38;2;102;217;239mstr[0m[38;2;248;248;242m>[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m->[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mResult[0m[38;2;248;248;242m<[0m[3;38;2;102;217;239mSelf[0m[38;2;248;248;242m>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;255;255;255mself[0m[38;2;248;248;242m::[0m[38;2;248;248;242mPagingMode[0m[38;2;248;248;242m::[0m[38;2;249;38;114m*[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[3;38;2;166;226;46mOk[0m[38;2;248;248;242m([0m[38;2;249;38;114mmatch[0m[38;2;248;248;242m mode [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m Always [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mtry_pager[0m[38;2;248;248;242m([0m[38;2;190;132;255mfalse[0m[38;2;248;248;242m,[0m[38;2;248;248;242m pager[0m[38;2;248;248;242m)[0m[38;2;249;38;114m?[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m QuitIfOneScreen [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mtry_pager[0m[38;2;248;248;242m([0m[38;2;190;132;255mtrue[0m[38;2;248;248;242m,[0m[38;2;248;248;242m pager[0m[38;2;248;248;242m)[0m[38;2;249;38;114m?[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m [0m[38;2;249;38;114m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mstdout[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[38;2;117;113;94m///[0m[38;2;117;113;94m Try to launch the pager. Fall back to stdout in case of errors.[0m -[38;2;248;248;242m [0m[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;248;248;242m [0m[3;38;2;102;217;239mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mtry_pager[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mquit_if_one_screen[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mbool[0m[38;2;248;248;242m, [0m[3;38;2;253;151;31mpager_from_config[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mOption[0m[38;2;248;248;242m<[0m[38;2;249;38;114m&[0m[3;38;2;102;217;239mstr[0m[38;2;248;248;242m>[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m->[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mResult[0m[38;2;248;248;242m<[0m[3;38;2;102;217;239mSelf[0m[38;2;248;248;242m>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;248;248;242mstd[0m[38;2;248;248;242m::[0m[38;2;248;248;242menv[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;248;248;242mstd[0m[38;2;248;248;242m::[0m[38;2;248;248;242mffi[0m[38;2;248;248;242m::[0m[38;2;248;248;242mOsString[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;248;248;242mstd[0m[38;2;248;248;242m::[0m[38;2;248;248;242mpath[0m[38;2;248;248;242m::[0m[38;2;248;248;242mPathBuf[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;249;38;114muse[0m[38;2;248;248;242m [0m[38;2;248;248;242mstd[0m[38;2;248;248;242m::[0m[38;2;248;248;242mprocess[0m[38;2;248;248;242m::[0m[38;2;248;248;242m{[0m[38;2;248;248;242mCommand[0m[38;2;248;248;242m,[0m[38;2;248;248;242m Stdio[0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m replace_arguments_to_less [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m pager_from_env [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114mmatch[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242menv[0m[38;2;248;248;242m::[0m[38;2;248;248;242mvar[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mBAT_PAGER[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242menv[0m[38;2;248;248;242m::[0m[38;2;248;248;242mvar[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mPAGER[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;248;248;242m([0m[3;38;2;166;226;46mOk[0m[38;2;248;248;242m([0m[38;2;248;248;242mbat_pager[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;249;38;114m_[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mSome[0m[38;2;248;248;242m([0m[38;2;248;248;242mbat_pager[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;249;38;114m_[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mOk[0m[38;2;248;248;242m([0m[38;2;248;248;242mpager[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m less needs to be called with the '-R' option in order to properly interpret the[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m ANSI color sequences printed by bat. If someone has set PAGER="less -F", we[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m therefore need to overwrite the arguments and add '-R'.[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m We only do this for PAGER (as it is not specific to 'bat'), not for BAT_PAGER[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m or bats '--pager' command line option.[0m -[38;2;248;248;242m replace_arguments_to_less [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[3;38;2;166;226;46mSome[0m[38;2;248;248;242m([0m[38;2;248;248;242mpager[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[38;2;249;38;114m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mNone[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m pager_from_config [0m[38;2;249;38;114m=[0m[38;2;248;248;242m pager_from_config[0m[38;2;248;248;242m.[0m[38;2;102;217;239mmap[0m[38;2;248;248;242m([0m[38;2;248;248;242m|[0m[3;38;2;253;151;31mp[0m[38;2;248;248;242m|[0m[38;2;248;248;242m [0m[38;2;248;248;242mp[0m[38;2;248;248;242m.[0m[38;2;102;217;239mto_string[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m pager_from_config[0m[38;2;248;248;242m.[0m[38;2;102;217;239mis_some[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m replace_arguments_to_less [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m pager [0m[38;2;249;38;114m=[0m[38;2;248;248;242m pager_from_config[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239mor[0m[38;2;248;248;242m([0m[38;2;248;248;242mpager_from_env[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239munwrap_or_else[0m[38;2;248;248;242m([0m[38;2;248;248;242m|[0m[38;2;248;248;242m|[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m[38;2;248;248;242m::[0m[38;2;248;248;242mfrom[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mless[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m pagerflags [0m[38;2;249;38;114m=[0m -[38;2;248;248;242m [0m[38;2;248;248;242mshell_words[0m[38;2;248;248;242m::[0m[38;2;248;248;242msplit[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[38;2;248;248;242mpager[0m[38;2;248;248;242m)[0m[38;2;248;248;242m.[0m[38;2;102;217;239mchain_err[0m[38;2;248;248;242m([0m[38;2;248;248;242m|[0m[38;2;248;248;242m|[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mCould not parse pager command.[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;249;38;114m?[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[38;2;249;38;114mmatch[0m[38;2;248;248;242m pagerflags[0m[38;2;248;248;242m.[0m[38;2;102;217;239msplit_first[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;166;226;46mSome[0m[38;2;248;248;242m([0m[38;2;248;248;242m([0m[38;2;248;248;242mpager_name[0m[38;2;248;248;242m,[0m[38;2;248;248;242m args[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m pager_path [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mPathBuf[0m[38;2;248;248;242m::[0m[38;2;248;248;242mfrom[0m[38;2;248;248;242m([0m[38;2;248;248;242mpager_name[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m pager_path[0m[38;2;248;248;242m.[0m[38;2;102;217;239mfile_stem[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mSome[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[38;2;248;248;242mOsString[0m[38;2;248;248;242m::[0m[38;2;248;248;242mfrom[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mbat[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m pager_path [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mPathBuf[0m[38;2;248;248;242m::[0m[38;2;248;248;242mfrom[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mless[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m is_less [0m[38;2;249;38;114m=[0m[38;2;248;248;242m pager_path[0m[38;2;248;248;242m.[0m[38;2;102;217;239mfile_stem[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mSome[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[38;2;248;248;242mOsString[0m[38;2;248;248;242m::[0m[38;2;248;248;242mfrom[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mless[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m process [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m is_less [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m p [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mCommand[0m[38;2;248;248;242m::[0m[38;2;248;248;242mnew[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[38;2;248;248;242mpager_path[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m args[0m[38;2;248;248;242m.[0m[38;2;102;217;239mis_empty[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m||[0m[38;2;248;248;242m replace_arguments_to_less [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m p[0m[38;2;248;248;242m.[0m[38;2;102;217;239marg[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116m--RAW-CONTROL-CHARS[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m quit_if_one_screen [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m p[0m[38;2;248;248;242m.[0m[38;2;102;217;239marg[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116m--quit-if-one-screen[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m versions of 'less'. Unfortunately, it also breaks mouse-wheel support.[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m See: http://www.greenwoodsoftware.com/less/news.530.html[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m For newer versions (530 or 558 on Windows), we omit '--no-init' as it[0m -[38;2;248;248;242m [0m[38;2;117;113;94m//[0m[38;2;117;113;94m is not needed anymore.[0m -[38;2;248;248;242m [0m[38;2;249;38;114mmatch[0m[38;2;248;248;242m [0m[38;2;102;217;239mretrieve_less_version[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;166;226;46mNone[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m p[0m[38;2;248;248;242m.[0m[38;2;102;217;239marg[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116m--no-init[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[3;38;2;166;226;46mSome[0m[38;2;248;248;242m([0m[38;2;248;248;242mversion[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mversion [0m[38;2;249;38;114m<[0m[38;2;248;248;242m [0m[38;2;190;132;255m530[0m[38;2;248;248;242m [0m[38;2;249;38;114m||[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mcfg![0m[38;2;248;248;242m([0m[38;2;248;248;242mwindows[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m&&[0m[38;2;248;248;242m version [0m[38;2;249;38;114m<[0m[38;2;248;248;242m [0m[38;2;190;132;255m558[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m -[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m p[0m[38;2;248;248;242m.[0m[38;2;102;217;239marg[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116m--no-init[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[38;2;249;38;114m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m p[0m[38;2;248;248;242m.[0m[38;2;102;217;239margs[0m[38;2;248;248;242m([0m[38;2;248;248;242margs[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m p[0m[38;2;248;248;242m.[0m[38;2;102;217;239menv[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mLESSCHARSET[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mUTF-8[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m p[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m p [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mCommand[0m[38;2;248;248;242m::[0m[38;2;248;248;242mnew[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[38;2;248;248;242mpager_path[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m p[0m[38;2;248;248;242m.[0m[38;2;102;217;239margs[0m[38;2;248;248;242m([0m[38;2;248;248;242margs[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m p[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m - -[38;2;248;248;242m [0m[3;38;2;166;226;46mOk[0m[38;2;248;248;242m([0m[38;2;248;248;242mprocess[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239mstdin[0m[38;2;248;248;242m([0m[38;2;248;248;242mStdio[0m[38;2;248;248;242m::[0m[38;2;248;248;242mpiped[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239mspawn[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239mmap[0m[38;2;248;248;242m([0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mPager[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239munwrap_or_else[0m[38;2;248;248;242m([0m[38;2;248;248;242m|[0m[38;2;248;248;242m_[0m[38;2;248;248;242m|[0m[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mstdout[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[3;38;2;166;226;46mNone[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mOk[0m[38;2;248;248;242m([0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mstdout[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[38;2;249;38;114mpub[0m[38;2;248;248;242m([0m[38;2;249;38;114mcrate[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mstdout[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mSelf[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mStdout[0m[38;2;248;248;242m([0m[38;2;248;248;242mio[0m[38;2;248;248;242m::[0m[38;2;248;248;242mstdout[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;248;248;242m [0m[38;2;249;38;114mpub[0m[38;2;248;248;242m([0m[38;2;249;38;114mcrate[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mis_pager[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[3;38;2;253;151;31mself[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mbool[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mPager[0m[38;2;248;248;242m([0m[38;2;249;38;114m_[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mself[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mnot[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;248;248;242m [0m[38;2;249;38;114mpub[0m[38;2;248;248;242m([0m[38;2;249;38;114mcrate[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mis_pager[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[3;38;2;253;151;31mself[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mbool[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m - -[38;2;248;248;242m [0m[38;2;249;38;114mpub[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mhandle[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[38;2;249;38;114mmut[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mself[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m->[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mResult[0m[38;2;248;248;242m<[0m[38;2;249;38;114m&[0m[38;2;249;38;114mmut[0m[38;2;248;248;242m dyn Write[0m[38;2;248;248;242m>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;166;226;46mOk[0m[38;2;248;248;242m([0m[38;2;249;38;114mmatch[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;255;255;255mself[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mPager[0m[38;2;248;248;242m([0m[38;2;249;38;114mref[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m command[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m command[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mstdin[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239mas_mut[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;102;217;239mchain_err[0m[38;2;248;248;242m([0m[38;2;248;248;242m|[0m[38;2;248;248;242m|[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mCould not open stdin for pager[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;249;38;114m?[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mStdout[0m[38;2;248;248;242m([0m[38;2;249;38;114mref[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m handle[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=>[0m[38;2;248;248;242m handle[0m[38;2;248;248;242m,[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m)[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m}[0m - -[38;2;248;248;242m#[0m[38;2;248;248;242m[[0m[38;2;248;248;242mcfg[0m[38;2;248;248;242m([0m[38;2;248;248;242mfeature [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpaging[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m][0m -[3;38;2;102;217;239mimpl[0m[38;2;248;248;242m [0m[38;2;248;248;242mDrop [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m [0m[38;2;166;226;46mOutputType[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;102;217;239mfn[0m[38;2;248;248;242m [0m[38;2;166;226;46mdrop[0m[38;2;248;248;242m([0m[38;2;249;38;114m&[0m[38;2;249;38;114mmut[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mself[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;248;248;242mOutputType[0m[38;2;248;248;242m::[0m[38;2;248;248;242mPager[0m[38;2;248;248;242m([0m[38;2;249;38;114mref[0m[38;2;248;248;242m [0m[38;2;249;38;114mmut[0m[38;2;248;248;242m command[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;255;255;255mself[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m -[38;2;248;248;242m [0m[3;38;2;102;217;239mlet[0m[38;2;248;248;242m [0m[38;2;249;38;114m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m command[0m[38;2;248;248;242m.[0m[38;2;102;217;239mwait[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m [0m[38;2;248;248;242m}[0m -[38;2;248;248;242m}[0m diff --git a/tests/syntax-tests/regression_test.sh b/tests/syntax-tests/regression_test.sh new file mode 100644 index 00000000..55e398c4 --- /dev/null +++ b/tests/syntax-tests/regression_test.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -eou pipefail + +script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +output_directory=$(mktemp -d --suffix=.bat-syntax-regression-test) + +"$script_directory"/create_highlighted_versions.py --output="$output_directory" + +echo + +"$script_directory"/compare_highlighted_versions.py \ + "$script_directory/highlighted" \ + "$output_directory" |