mirror of
https://github.com/vlang/v.git
synced 2025-09-18 11:56:57 -04:00
v: utilize new diff functions p1 (#21431)
This commit is contained in:
parent
97984adaf3
commit
ee22dcb0f6
@ -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('============')
|
||||
|
@ -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'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user