-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from cgbur/latest-zig
Add CLI testing to CI
- Loading branch information
Showing
16 changed files
with
153 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import subprocess | ||
import difflib | ||
|
||
|
||
def run_test(test_file): | ||
with open(test_file, "r") as f: | ||
lines = f.readlines() | ||
cmd = lines[0].strip() | ||
expected_output = "".join(lines[1:]) | ||
actual_output = subprocess.check_output(cmd, shell=True).decode("utf-8").strip() | ||
|
||
return expected_output == actual_output, expected_output, actual_output | ||
|
||
|
||
def print_diff(expected_output, actual_output): | ||
diff = difflib.unified_diff( | ||
expected_output.splitlines(keepends=True), | ||
actual_output.splitlines(keepends=True), | ||
fromfile="Expected", | ||
tofile="Actual", | ||
) | ||
print("\nDifference (Expected vs Actual):") | ||
print("".join(diff), end="") | ||
|
||
|
||
def main(): | ||
test_dir = "tests" | ||
passed = 0 | ||
failed = 0 | ||
files = sorted(os.listdir(test_dir)) | ||
for test_file in files: | ||
success, expected_output, actual_output = run_test( | ||
os.path.join(test_dir, test_file) | ||
) | ||
if success: | ||
passed += 1 | ||
print(f"\033[92m✔ {test_file}: Test passed\033[0m") | ||
else: | ||
failed += 1 | ||
print(f"\033[91m✖ {test_file}: Test failed\033[0m") | ||
print_diff(expected_output, actual_output) | ||
print() | ||
print() | ||
|
||
# Summary | ||
print("\nTest Summary") | ||
print(f"Passed: \033[92m{passed}\033[0m") | ||
print(f"Failed: \033[91m{failed}\033[0m") | ||
|
||
if failed > 0: | ||
exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pc 1 23 40000 | ||
↑ 2200% 23x [ 1 → 23 ] | ||
↑ 173813% 1739x [ 23B → 39KiB ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pc 400000 123 12312412312312312 0 0 0 1 0 | ||
↓ -100.0% 0.00x [ 390.6KiB → 123.0B ] | ||
↑ 10010091298226176% 100100915331072x [ 123B → 11PiB ] | ||
↓ -100% 0x [ 11PiB → 0B ] | ||
→ 0% 0x [ 0 → 0 ] | ||
→ 0% 0x [ 0 → 0 ] | ||
↑ inf% infx [ 0 → 1 ] | ||
↓ -100% 0x [ 1 → 0 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pc 10 11 200 2000 2000000 1999999 | ||
↑ 10% 1.10x [ 10 → 11 ] | ||
↑ 1718% 18.2x [ 11 → 200 ] | ||
↑ 900% 10x [ 200B → 2KiB ] | ||
↑ 99900% 1000x [ 2KiB → 2MiB ] | ||
↓ -0.00% 1.00x [ 1.91MiB → 1.91MiB ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pc 18024 19503 11124 12321 340200 424212 1000000000 | ||
↑ 8.21% 1.08x [ 17.60KiB → 19.05KiB ] | ||
↓ -43.0% 0.57x [ 19.0KiB → 10.9KiB ] | ||
↑ 10.8% 1.11x [ 10.9KiB → 12.0KiB ] | ||
↑ 2661% 27.6x [ 12KiB → 332KiB ] | ||
↑ 24.7% 1.25x [ 332.2KiB → 414.3KiB ] | ||
↑ 235631% 2357x [ 414KiB → 954MiB ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pc 50 1200 3432 23 0 0 --format csv | ||
percent,times,prev,cur | ||
2300,24,50,1200 | ||
186,2.859999895095825,1200,3432 | ||
-99.329833984375,0.006701631471514702,3432,23 | ||
-100,0,23,0 | ||
0,0,0,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
echo "15@20@3 6" | pc -d "@" | ||
↑ 33.3% 1.33x [ 15 → 20 ] | ||
↓ -85% 0.15x [ 20 → 3 ] | ||
↑ 100% 2x [ 3 → 6 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
echo 100 2000 20 | pc | ||
↑ 1900% 20x [ 100B → 2KiB ] | ||
↓ -99% 0.01x [ 2KiB → 20B ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pc 1 2 3 4 -f | ||
↑ 100% 2x [ 1 → 2 ] | ||
↑ 200% 3x [ 1 → 3 ] | ||
↑ 300% 4x [ 1 → 4 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pc 1 2 3 4 -f 2 | ||
↓ -50% 0.50x [ 2 → 1 ] | ||
↑ 50% 1.50x [ 2 → 3 ] | ||
↑ 100% 2x [ 2 → 4 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pc 1 2 3 4 -f -1 | ||
↓ -75% 0.25x [ 4 → 1 ] | ||
↓ -50% 0.50x [ 4 → 2 ] | ||
↓ -25% 0.75x [ 4 → 3 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pc 50 1200 3432 23 0 0 --format json | ||
[{"percent":2.3e+03,"times":2.4e+01,"prev":5.0e+01,"cur":1.2e+03},{"percent":1.86e+02,"times":2.859999895095825e+00,"prev":1.2e+03,"cur":3.432e+03},{"percent":-9.9329833984375e+01,"times":6.701631471514702e-03,"prev":3.432e+03,"cur":2.3e+01},{"percent":-1.0e+02,"times":0.0e+00,"prev":2.3e+01,"cur":0.0e+00},{"percent":0.0e+00,"times":0.0e+00,"prev":0.0e+00,"cur":0.0e+00}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pc 400000 123 12312412312312312 0 0 0 1 0 --raw | ||
↓ -100.0% 0.00x [ 400000 → 123 ] | ||
↑ 10010091298226176% 100100915331072x [ 123 → 12312412812214272 ] | ||
↓ -100% 0x [ 12312412812214272 → 0 ] | ||
→ 0% 0x [ 0 → 0 ] | ||
→ 0% 0x [ 0 → 0 ] | ||
↑ inf% infx [ 0 → 1 ] | ||
↓ -100% 0x [ 1 → 0 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pc --help | pc | ||
→ 0% 1x [ 2 → 2 ] | ||
→ 0% 1x [ 2 → 2 ] | ||
→ 0% 1x [ 2 → 2 ] | ||
↓ -150% -0.50x [ 2 → -1 ] | ||
↑ 100000096% -1000000x [ -1 → 1000000 ] | ||
↓ -100.0% 0.00x [ 976.6KiB → 2.0B ] | ||
↑ 400% 5x [ 2 → 10 ] | ||
↑ 100% 2x [ 10 → 20 ] | ||
↑ 50% 1.50x [ 20 → 30 ] | ||
↓ -33.3% 0.67x [ 30 → 20 ] | ||
↑ 1005% 11.1x [ 20 → 221 ] | ||
→ 0% 1x [ 221 → 221 ] |