Skip to content

Commit

Permalink
fixup tolerate windows
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Aug 15, 2024
1 parent f4e17c7 commit c94e077
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/it.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,27 @@
# SPDX-License-Identifier: Apache-2.0

from pathlib import Path
import difflib
import subprocess

def diff_files(file1, file2):
with file1.open("r") as f1, file2.open("r") as f2:
diff = difflib.unified_diff(f1.readlines(), f2.readlines(), str(file1), str(file2))
diff = list(diff)
if diff:
for line in diff:
print(line, end="")
exit(1)


basedir = Path(__file__).parent.absolute()
rootdir = basedir.parent

subprocess.run(["cargo", "build", "--bin", "hawkeye"], cwd=rootdir, check=True)
hawkeye = rootdir / "target" / "debug" / "hawkeye"

subprocess.run([hawkeye, "format", "--fail-if-unknown", "--fail-if-updated=false", "--dry-run"], cwd=(basedir / "load_header_path"), check=True)
subprocess.run(["diff", "main.rs.expected", "main.rs.formatted"], cwd=(basedir / "load_header_path"), check=True)
diff_files(basedir / "load_header_path" / "main.rs.expected", basedir / "load_header_path" / "main.rs.formatted")

subprocess.run([hawkeye, "format", "--fail-if-unknown", "--fail-if-updated=false", "--dry-run"], cwd=(basedir / "regression_blank_line"), check=True)
subprocess.run(["diff", "main.rs.expected", "main.rs.formatted"], cwd=(basedir / "regression_blank_line"), check=True)
diff_files(basedir / "regression_blank_line" / "main.rs.expected", basedir / "regression_blank_line" / "main.rs.formatted")

0 comments on commit c94e077

Please sign in to comment.