Skip to content

Commit

Permalink
v: utilize new diff functions p1 (#21431)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed May 5, 2024
1 parent 97984ad commit ee22dcb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
7 changes: 3 additions & 4 deletions vlib/v/compiler_errors_test.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import rand
import term
import v.util.diff
import v.util.vtest
Expand Down Expand Up @@ -409,10 +408,10 @@ fn chunka(s []u8, chunk_size int) string {

fn diff_content(expected string, found string) {
println(term.bold(term.yellow('diff: ')))
if diff_cmd := diff.find_working_diff_command() {
println(diff.color_compare_strings(diff_cmd, rand.ulid(), expected, found))
if diff_ := diff.compare_text(expected, found) {
println(diff_)
} else {
println('>>>> could not find a working diff command; dumping bytes instead...')
println('>>>> `${err}`; dumping bytes instead...')
println('expected bytes:\n${chunka(expected.bytes(), 25)}')
println(' found bytes:\n${chunka(found.bytes(), 25)}')
println('============')
Expand Down
15 changes: 8 additions & 7 deletions vlib/v/slow_tests/inout/compiler_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ fn test_all() {
}
if expected != found {
println(term.red('FAIL'))
println(term.header('expected:', '-'))
println(expected)
println(term.header('found:', '-'))
println(found)
if diff_cmd != '' {
if diff_ := diff.compare_text(expected, found) {
println(term.header('difference:', '-'))
println(diff.color_compare_strings(diff_cmd, rand.ulid(), expected, found))
println(diff_)
} else {
println(term.h_divider('-'))
println(err)
println(term.header('expected:', '-'))
println(expected)
println(term.header('found:', '-'))
println(found)
}
println(term.h_divider('-'))
total_errors++
} else {
println(term.green('OK'))
Expand Down

0 comments on commit ee22dcb

Please sign in to comment.