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

all: reimplement inline assembly (#8645)

This commit is contained in:
crthpl
2021-03-16 17:43:17 -07:00
committed by GitHub
parent dd9f9c2718
commit fafb035fb5
29 changed files with 2089 additions and 335 deletions

View File

@ -196,11 +196,6 @@ pub fn (mut ts TestSession) test() {
continue
}
}
$if tinyc {
if file.contains('asm') {
continue
}
}
remaining_files << dot_relative_file
}
remaining_files = vtest.filter_vtest_only(remaining_files, fix_slashes: false)

View File

@ -3,6 +3,7 @@ module main
import os
import os.cmdline
import testing
import v.pref
fn main() {
args := os.args.clone()
@ -18,20 +19,35 @@ fn main() {
eprintln('Use `v test-all` instead.')
exit(1)
}
backend_pos := args_before.index('-b')
backend := if backend_pos == -1 { '.c' } else { args_before[backend_pos + 1] } // this giant mess because closures are not implemented
mut ts := testing.new_test_session(args_before.join(' '))
for targ in args_after {
if os.exists(targ) && targ.ends_with('_test.v') {
ts.files << targ
continue
}
if os.is_dir(targ) {
// Fetch all tests from the directory
ts.files << os.walk_ext(targ.trim_right(os.path_separator), '_test.v')
files, skip_files := should_test_dir(targ.trim_right(os.path_separator), backend)
ts.files << files
ts.skip_files << skip_files
continue
} else if os.exists(targ) {
match should_test(targ, backend) {
.test {
ts.files << targ
continue
}
.skip {
ts.files << targ
ts.skip_files << targ
continue
}
.ignore {}
}
} else {
eprintln('\nUnrecognized test file `$targ`.\n `v test` can only be used with folders and/or _test.v files.\n')
show_usage()
exit(1)
}
eprintln('\nUnrecognized test file `$targ` .\n `v test` can only be used with folders and/or _test.v files.\n')
show_usage()
exit(1)
}
testing.header('Testing...')
ts.test()
@ -52,3 +68,65 @@ fn show_usage() {
println(' NB: you can also give many and mixed folder/ file_test.v arguments after `v test` .')
println('')
}
pub fn should_test_dir(path string, backend string) ([]string, []string) { // return is (files, skip_files)
mut files := os.ls(path) or { return []string{}, []string{} }
mut local_path_separator := os.path_separator
if path.ends_with(os.path_separator) {
local_path_separator = ''
}
mut res_files := []string{}
mut skip_files := []string{}
for file in files {
p := path + local_path_separator + file
if os.is_dir(p) && !os.is_link(p) {
ret_files, ret_skip_files := should_test_dir(p, backend)
res_files << ret_files
skip_files << ret_skip_files
} else if os.exists(p) {
match should_test(p, backend) {
.test {
res_files << p
}
.skip {
res_files << p
skip_files << p
}
.ignore {}
}
}
}
return res_files, skip_files
}
enum ShouldTestStatus {
test // do test
skip
ignore
}
fn should_test(path string, backend string) ShouldTestStatus {
if path.ends_with('_test.v') {
return .test
}
if path.ends_with('.v') && path.count('.') == 2 {
if !path.all_before_last('.v').all_before_last('.').ends_with('_test') {
return .ignore
}
backend_arg := path.all_before_last('.v').all_after_last('.')
arch := pref.arch_from_string(backend_arg) or { pref.Arch._auto }
if arch == pref.get_host_arch() {
return .test
} else if arch == ._auto {
if backend_arg == 'c' { // .c.v
return if backend == 'c' { ShouldTestStatus.test } else { ShouldTestStatus.skip }
}
if backend_arg == 'js' {
return if backend == 'js' { ShouldTestStatus.test } else { ShouldTestStatus.skip }
}
} else {
return .skip
}
}
return .ignore
}