tools: make `v test vlib` and `v test-self` skip _test.js.v files, when `node` is not installed
parent
c29a3cf6e8
commit
7bbc70820a
|
@ -19,6 +19,10 @@ pub const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
|||
|
||||
pub const fail_fast = os.getenv('VTEST_FAIL_FAST') == '1'
|
||||
|
||||
pub const is_node_present = os.execute('node --version').exit_code == 0
|
||||
|
||||
pub const all_processes = os.execute('ps ax').output.split_any('\r\n')
|
||||
|
||||
pub struct TestSession {
|
||||
pub mut:
|
||||
files []string
|
||||
|
@ -551,3 +555,12 @@ pub fn get_test_details(file string) TestDetails {
|
|||
}
|
||||
return res
|
||||
}
|
||||
|
||||
pub fn find_started_process(pname string) ?string {
|
||||
for line in testing.all_processes {
|
||||
if line.contains(pname) {
|
||||
return line
|
||||
}
|
||||
}
|
||||
return error('could not find process matching $pname')
|
||||
}
|
||||
|
|
|
@ -147,12 +147,22 @@ fn main() {
|
|||
cmd_prefix := args_string.all_before('test-self')
|
||||
title := 'testing vlib'
|
||||
mut all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
|
||||
all_test_files << os.walk_ext(os.join_path(vroot, 'vlib'), '_test.js.v')
|
||||
test_js_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.js.v')
|
||||
all_test_files << test_js_files
|
||||
testing.eheader(title)
|
||||
mut tsession := testing.new_test_session(cmd_prefix, true)
|
||||
tsession.files << all_test_files.filter(!it.contains('testdata' + os.path_separator))
|
||||
tsession.skip_files << skip_test_files
|
||||
|
||||
if !testing.is_node_present {
|
||||
testroot := vroot + os.path_separator
|
||||
tsession.skip_files << test_js_files.map(it.replace(testroot, ''))
|
||||
}
|
||||
testing.find_started_process('mysqld') or {
|
||||
tsession.skip_files << 'vlib/mysql/mysql_orm_test.v'
|
||||
}
|
||||
testing.find_started_process('postgres') or { tsession.skip_files << 'vlib/pg/pg_orm_test.v' }
|
||||
|
||||
if github_job == 'windows-tcc' {
|
||||
// TODO: fix these ASAP
|
||||
tsession.skip_files << 'vlib/net/tcp_test.v'
|
||||
|
|
|
@ -105,18 +105,35 @@ pub fn should_test_dir(path string, backend string) ([]string, []string) { // re
|
|||
}
|
||||
|
||||
enum ShouldTestStatus {
|
||||
test // do test
|
||||
skip
|
||||
ignore
|
||||
test // do test, print OK or FAIL, depending on if it passes
|
||||
skip // print SKIP for the test
|
||||
ignore // just ignore the file, so it will not be printed at all in the list of tests
|
||||
}
|
||||
|
||||
fn should_test(path string, backend string) ShouldTestStatus {
|
||||
if path.ends_with('mysql_orm_test.v') {
|
||||
testing.find_started_process('mysqld') or { return .skip }
|
||||
}
|
||||
if path.ends_with('pg_orm_test.v') {
|
||||
testing.find_started_process('postgres') or { return .skip }
|
||||
}
|
||||
if path.ends_with('onecontext_test.v') {
|
||||
return .skip
|
||||
}
|
||||
$if tinyc {
|
||||
if path.ends_with('naked_attr_test.amd64.v') {
|
||||
return .skip
|
||||
}
|
||||
}
|
||||
if path.ends_with('_test.v') {
|
||||
return .test
|
||||
}
|
||||
if path.ends_with('_test.js.v') {
|
||||
if testing.is_node_present {
|
||||
return .test
|
||||
}
|
||||
return .skip
|
||||
}
|
||||
if path.ends_with('.v') && path.count('.') == 2 {
|
||||
if !path.all_before_last('.v').all_before_last('.').ends_with('_test') {
|
||||
return .ignore
|
||||
|
|
Loading…
Reference in New Issue