Skip to content

Commit b5b84f1

Browse files
committed
chore: more readable output of utils.nu test_format
1 parent 723d694 commit b5b84f1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

run_test.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $env.TOPIARY_CONFIG_FILE = (pwd | path join languages.ncl)
99
$env.TOPIARY_LANGUAGE_DIR = (pwd | path join languages)
1010

1111
for f in $files {
12-
print $"Testing: (ansi green_bold)($f)(ansi reset)"
12+
print $"(ansi green)Testing: (ansi yellow)($f)(ansi reset)"
1313
cp $f $temp_file
1414
topiary format $temp_file
1515
let expected_file = $f | str replace --regex '/input_' '/expected_'

utils.nu

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ def print_progress [
2626
let done = ''
2727
let empty = ''
2828
let count = [1 (($ratio * $length) | into int)] | math max
29-
print -n (str_repeat $done $count) (str_repeat $empty ($length - $count)) ($ratio * 100 | into string --decimals 0) %
29+
(
30+
print -n
31+
(str_repeat $done $count)
32+
(str_repeat $empty ($length - $count))
33+
($ratio * 100 | into string --decimals 0) %
34+
)
3035
}
3136

3237
# Test the topiary formatter with all nu files within a directory
@@ -38,6 +43,7 @@ export def test_format [
3843
let files = glob $'($path | str trim -r -c '/')/**/*.nu'
3944
let target = "./test.nu"
4045
let len = $files | length
46+
$env.format_detected_error = false
4147
for i in 1..$len {
4248
let file = $files | get ($i - 1)
4349
print_progress ($i / $len)
@@ -49,11 +55,17 @@ export def test_format [
4955
let err_after = run_ide_check $target
5056
assert ($err_before == $err_after)
5157
} catch {
52-
print $file
58+
$env.format_detected_error = true
59+
print $"(ansi red)Error detected: (ansi yellow)($file)(ansi reset)"
5360
if $break {
61+
rm $target
5462
break
5563
}
5664
}
5765
rm $target
5866
}
67+
if not $env.format_detected_error {
68+
print ''
69+
print $"(ansi green)All nu scripts successfully passed the check, but style issues are still possible."
70+
}
5971
}

0 commit comments

Comments
 (0)