v: utilize new diff functions p1 (#21431)

This commit is contained in:
Turiiya 2024-05-05 14:59:58 +02:00 committed by GitHub
parent 97984adaf3
commit ee22dcb0f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 11 deletions

View File

@ -1,5 +1,4 @@
import os
import rand
import term
import v.util.diff
import v.util.vtest
@ -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('============')

View File

@ -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'))