mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: fix failing tests on windows too
This commit is contained in:
parent
5d4cce3e95
commit
50a2b033b7
@ -5,7 +5,6 @@ import strings
|
||||
#flag -lws2_32
|
||||
#include <winsock2.h>
|
||||
#include <process.h>
|
||||
|
||||
pub const (
|
||||
path_separator = '\\'
|
||||
path_delimiter = ';'
|
||||
@ -131,12 +130,12 @@ pub fn is_dir(path string) bool {
|
||||
return false
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// mkdir creates a new directory with the specified path.
|
||||
pub fn mkdir(path string) ?bool {
|
||||
if path == '.' { return true }
|
||||
apath := os.real_path( path )
|
||||
if path == '.' {
|
||||
return true
|
||||
}
|
||||
apath := real_path(path)
|
||||
if !C.CreateDirectory(apath.to_wide(), 0) {
|
||||
return error('mkdir failed for "$apath", because CreateDirectory returned ' + get_error_msg(int(C.GetLastError())))
|
||||
}
|
||||
@ -146,7 +145,9 @@ pub fn mkdir(path string) ?bool {
|
||||
// Ref - https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle?view=vs-2019
|
||||
// get_file_handle retrieves the operating-system file handle that is associated with the specified file descriptor.
|
||||
pub fn get_file_handle(path string) HANDLE {
|
||||
cfile := vfopen(path, 'rb') or { return HANDLE(invalid_handle_value) }
|
||||
cfile := vfopen(path, 'rb') or {
|
||||
return HANDLE(invalid_handle_value)
|
||||
}
|
||||
handle := HANDLE(C._get_osfhandle(fileno(cfile))) // CreateFile? - hah, no -_-
|
||||
return handle
|
||||
}
|
||||
@ -204,10 +205,7 @@ fn ptr_win_get_error_msg(code u32) voidptr {
|
||||
if code > u32(max_error_code) {
|
||||
return buf
|
||||
}
|
||||
C.FormatMessage(
|
||||
format_message_allocate_buffer
|
||||
| format_message_from_system
|
||||
| format_message_ignore_inserts,
|
||||
C.FormatMessage(format_message_allocate_buffer | format_message_from_system | format_message_ignore_inserts,
|
||||
0, code, C.MAKELANGID(lang_neutral, sublang_default), voidptr(&buf), 0, 0)
|
||||
return buf
|
||||
}
|
||||
@ -235,21 +233,20 @@ pub fn exec(cmd string) ?Result {
|
||||
mut sa := SecurityAttributes{}
|
||||
sa.n_length = sizeof(C.SECURITY_ATTRIBUTES)
|
||||
sa.b_inherit_handle = true
|
||||
|
||||
create_pipe_ok := C.CreatePipe(voidptr(&child_stdout_read),
|
||||
voidptr(&child_stdout_write), voidptr(&sa), 0)
|
||||
create_pipe_ok := C.CreatePipe(voidptr(&child_stdout_read), voidptr(&child_stdout_write),
|
||||
voidptr(&sa), 0)
|
||||
if !create_pipe_ok {
|
||||
error_num := int(C.GetLastError())
|
||||
error_msg := get_error_msg(error_num)
|
||||
return error_with_code('exec failed (CreatePipe): $error_msg', error_num)
|
||||
}
|
||||
set_handle_info_ok := C.SetHandleInformation(child_stdout_read, C.HANDLE_FLAG_INHERIT, 0)
|
||||
set_handle_info_ok := C.SetHandleInformation(child_stdout_read, C.HANDLE_FLAG_INHERIT,
|
||||
0)
|
||||
if !set_handle_info_ok {
|
||||
error_num := int(C.GetLastError())
|
||||
error_msg := get_error_msg(error_num)
|
||||
return error_with_code('exec failed (SetHandleInformation): $error_msg', error_num)
|
||||
}
|
||||
|
||||
proc_info := ProcessInformation{}
|
||||
start_info := StartupInfo{
|
||||
lp_reserved: 0
|
||||
@ -263,11 +260,13 @@ pub fn exec(cmd string) ?Result {
|
||||
}
|
||||
command_line := [32768]u16{}
|
||||
C.ExpandEnvironmentStringsW(cmd.to_wide(), voidptr(&command_line), 32768)
|
||||
create_process_ok := C.CreateProcessW(0, command_line, 0, 0, C.TRUE, 0, 0, 0, voidptr(&start_info), voidptr(&proc_info))
|
||||
create_process_ok := C.CreateProcessW(0, command_line, 0, 0, C.TRUE, 0, 0, 0, voidptr(&start_info),
|
||||
voidptr(&proc_info))
|
||||
if !create_process_ok {
|
||||
error_num := int(C.GetLastError())
|
||||
error_msg := get_error_msg(error_num)
|
||||
return error_with_code('exec failed (CreateProcess) with code $error_num: $error_msg cmd: $cmd', error_num)
|
||||
return error_with_code('exec failed (CreateProcess) with code $error_num: $error_msg cmd: $cmd',
|
||||
error_num)
|
||||
}
|
||||
C.CloseHandle(child_stdin)
|
||||
C.CloseHandle(child_stdout_write)
|
||||
@ -275,7 +274,8 @@ pub fn exec(cmd string) ?Result {
|
||||
mut bytes_read := u32(0)
|
||||
mut read_data := strings.new_builder(1024)
|
||||
for {
|
||||
readfile_result := C.ReadFile(child_stdout_read, buf, 1000, voidptr(&bytes_read), 0)
|
||||
readfile_result := C.ReadFile(child_stdout_read, buf, 1000, voidptr(&bytes_read),
|
||||
0)
|
||||
read_data.write_bytes(buf, int(bytes_read))
|
||||
if readfile_result == false || int(bytes_read) == 0 {
|
||||
break
|
||||
@ -296,8 +296,8 @@ pub fn exec(cmd string) ?Result {
|
||||
|
||||
fn C.CreateSymbolicLinkW(&u16, &u16, u32) int
|
||||
|
||||
pub fn symlink(origin, target string) ?bool {
|
||||
flags := if os.is_dir(origin) { 1 } else { 0 }
|
||||
pub fn symlink(origin string, target string) ?bool {
|
||||
flags := if is_dir(origin) { 1 } else { 0 }
|
||||
if C.CreateSymbolicLinkW(origin.to_wide(), target.to_wide(), u32(flags)) != 0 {
|
||||
return true
|
||||
}
|
||||
@ -318,7 +318,6 @@ pub:
|
||||
// status_ constants
|
||||
code u32
|
||||
flags u32
|
||||
|
||||
record &ExceptionRecord
|
||||
address voidptr
|
||||
param_count u32
|
||||
@ -339,18 +338,15 @@ pub type VectoredExceptionHandler = fn (&ExceptionPointers) u32
|
||||
|
||||
// This is defined in builtin because we use vectored exception handling
|
||||
// for our unhandled exception handler on windows
|
||||
|
||||
// As a result this definition is commented out to prevent
|
||||
// duplicate definitions from displeasing the compiler
|
||||
// fn C.AddVectoredExceptionHandler(u32, VectoredExceptionHandler)
|
||||
|
||||
pub fn add_vectored_exception_handler(first bool, handler VectoredExceptionHandler) {
|
||||
C.AddVectoredExceptionHandler(u32(first), C.PVECTORED_EXCEPTION_HANDLER(handler))
|
||||
}
|
||||
|
||||
// this is defined in builtin_windows.c.v in builtin
|
||||
// fn C.IsDebuggerPresent() bool
|
||||
|
||||
pub fn debugger_present() bool {
|
||||
return C.IsDebuggerPresent()
|
||||
}
|
||||
@ -367,25 +363,25 @@ pub fn uname() Uname {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// `is_writable_folder` - `folder` exists and is writable to the process
|
||||
pub fn is_writable_folder(folder string) ?bool {
|
||||
if !os.exists(folder) {
|
||||
if !exists(folder) {
|
||||
return error('`$folder` does not exist')
|
||||
}
|
||||
if !os.is_dir(folder) {
|
||||
if !is_dir(folder) {
|
||||
return error('`folder` is not a folder')
|
||||
}
|
||||
tmp_perm_check := os.join_path(folder, 'tmp_perm_check_pid_' + getpid().str())
|
||||
mut f := os.open_file(tmp_perm_check, 'w+', 0o700) or {
|
||||
tmp_perm_check := join_path(folder, 'tmp_perm_check_pid_' + getpid().str())
|
||||
mut f := open_file(tmp_perm_check, 'w+', 0o700) or {
|
||||
return error('cannot write to folder $folder: $err')
|
||||
}
|
||||
f.close()
|
||||
os.rm(tmp_perm_check)
|
||||
rm(tmp_perm_check)
|
||||
return true
|
||||
}
|
||||
|
||||
fn C._getpid() int
|
||||
|
||||
[inline]
|
||||
pub fn getpid() int {
|
||||
return C._getpid()
|
||||
|
@ -9,8 +9,8 @@ import benchmark
|
||||
|
||||
const (
|
||||
skip_files = [
|
||||
'vlib/v/checker/tests/return_missing_comp_if.vv'
|
||||
'vlib/v/checker/tests/return_missing_comp_if_nested.vv'
|
||||
'vlib/v/checker/tests/return_missing_comp_if.vv',
|
||||
'vlib/v/checker/tests/return_missing_comp_if_nested.vv',
|
||||
]
|
||||
)
|
||||
|
||||
@ -46,7 +46,8 @@ fn test_all() {
|
||||
// -prod so that warns are errors
|
||||
mut tasks := []TaskDescription{}
|
||||
tasks << new_tasks(vexe, classic_dir, '-prod', '.out', classic_tests, false)
|
||||
tasks << new_tasks(vexe, global_dir, '--enable-globals', '.out', global_tests, false)
|
||||
tasks <<
|
||||
new_tasks(vexe, global_dir, '--enable-globals', '.out', global_tests, false)
|
||||
tasks <<
|
||||
new_tasks(vexe, classic_dir, '--enable-globals run', '.run.out', ['globals_error.vv'], false)
|
||||
tasks << new_tasks(vexe, module_dir, '-prod run', '.out', module_tests, true)
|
||||
@ -55,7 +56,7 @@ fn test_all() {
|
||||
tasks.run()
|
||||
}
|
||||
|
||||
fn new_tasks(vexe, dir, voptions, result_extension string, tests []string, is_module bool) []TaskDescription {
|
||||
fn new_tasks(vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) []TaskDescription {
|
||||
paths := vtest.filter_vtest_only(tests, {
|
||||
basepath: dir
|
||||
})
|
||||
@ -88,9 +89,7 @@ fn (mut tasks []TaskDescription) run() {
|
||||
if tasks[i].path in m_skip_files {
|
||||
tasks[i].is_skipped = true
|
||||
}
|
||||
unsafe {
|
||||
work.push(&tasks[i])
|
||||
}
|
||||
unsafe {work.push(&tasks[i])}
|
||||
}
|
||||
work.close()
|
||||
for _ in 0 .. vjobs {
|
||||
@ -181,7 +180,7 @@ fn clean_line_endings(s string) string {
|
||||
return res
|
||||
}
|
||||
|
||||
fn diff_content(s1, s2 string) {
|
||||
fn diff_content(s1 string, s2 string) {
|
||||
diff_cmd := util.find_working_diff_command() or {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user