1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: fix a race in vlib/v/compiler_errors_test.v execution on m1

This commit is contained in:
Delyan Angelov 2021-04-05 22:57:53 +03:00
parent b041681c00
commit 10619d098c
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
6 changed files with 12 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import v.util
import v.pref
import v.builder
import v.ast
import rand
import term
const (
@ -116,7 +117,7 @@ fn (app App) gen_api_for_module_in_os(mod_name string, os_name string) string {
}
fn (mut app App) compare_api(api_base string, api_os string, mod_name string, os_base string, os_target string) {
res := util.color_compare_strings(app.diff_cmd, api_base, api_os)
res := util.color_compare_strings(app.diff_cmd, rand.ulid(), api_base, api_os)
if res.len > 0 {
summary := 'Different APIs found for module: `$mod_name`, between OS base: `$os_base` and OS: `$os_target`'
eprintln(term.header(summary, '-'))

View File

@ -1,4 +1,5 @@
import os
import rand
import term
import v.util.vtest
import v.util
@ -51,7 +52,7 @@ fn check_path(vexe string, dir string, tests []string) int {
println(found)
println('============\n')
println('diff:')
println(util.color_compare_strings(diff_cmd, found, expected))
println(util.color_compare_strings(diff_cmd, rand.ulid(), found, expected))
println('============\n')
nb_fail++
} else {

View File

@ -536,7 +536,7 @@ pub fn on_segfault(f voidptr) {
return
}
$if macos {
C.printf('TODO')
C.printf(c'TODO')
/*
mut sa := C.sigaction{}
C.memset(&sa, 0, sizeof(C.sigaction_size))

View File

@ -1,4 +1,5 @@
import os
import rand
import term
import v.util
import v.util.vtest
@ -315,7 +316,7 @@ fn clean_line_endings(s string) string {
fn diff_content(s1 string, s2 string) {
diff_cmd := util.find_working_diff_command() or { return }
println(term.bold(term.yellow('diff: ')))
println(util.color_compare_strings(diff_cmd, s1, s2))
println(util.color_compare_strings(diff_cmd, rand.ulid(), s1, s2))
println('============\n')
}

View File

@ -2,6 +2,7 @@
// To test a panic, remove everything after the long `===` line
// You can also remove the line with 'line:' e.g. for a builtin fn
import os
import rand
import term
import v.util
import v.util.vtest
@ -77,7 +78,7 @@ fn test_all() {
println(found)
if diff_cmd != '' {
println(term.header('difference:', '-'))
println(util.color_compare_strings(diff_cmd, expected, found))
println(util.color_compare_strings(diff_cmd, rand.ulid(), expected, found))
} else {
println(term.h_divider('-'))
}

View File

@ -68,11 +68,11 @@ pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string {
return ''
}
pub fn color_compare_strings(diff_cmd string, expected string, found string) string {
pub fn color_compare_strings(diff_cmd string, unique_prefix string, expected string, found string) string {
cdir := os.cache_dir()
ctime := time.sys_mono_now()
e_file := os.join_path(cdir, '${ctime}.expected.txt')
f_file := os.join_path(cdir, '${ctime}.found.txt')
e_file := os.join_path(cdir, '${unique_prefix}_${ctime}.expected.txt')
f_file := os.join_path(cdir, '${unique_prefix}_${ctime}.found.txt')
os.write_file(e_file, expected) or { panic(err) }
os.write_file(f_file, found) or { panic(err) }
res := color_compare_files(diff_cmd, e_file, f_file)