From f43b52860dcdd70d8f79397f1dd94812d44ee8a7 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 13 Feb 2024 18:36:51 +0200 Subject: [PATCH] tools: use the same same skipping logic for the platform specific _test.v files in `v test-self` too (#20815) --- cmd/tools/modules/testing/common.v | 19 +++++++++++++++++++ cmd/tools/vtest-self.v | 4 ---- cmd/tools/vtest.v | 14 -------------- .../filtering_android_outside_termux_test.v | 0 .../filtering_macos_test.v | 0 .../filtering_nix_test.v | 0 .../filtering_windows_test.v | 0 7 files changed, 19 insertions(+), 18 deletions(-) rename vlib/v/tests/{ => filtering_tests}/filtering_android_outside_termux_test.v (100%) rename vlib/v/tests/{ => filtering_tests}/filtering_macos_test.v (100%) rename vlib/v/tests/{ => filtering_tests}/filtering_nix_test.v (100%) rename vlib/v/tests/{ => filtering_tests}/filtering_windows_test.v (100%) diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index f5c3b8b86a418c..efa37c21a6cef3 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -13,6 +13,8 @@ import runtime import rand import strings +pub const host_os = pref.get_host_os() + pub const github_job = os.getenv('GITHUB_JOB') pub const runner_os = os.getenv('RUNNER_OS') // GitHub runner OS @@ -386,6 +388,23 @@ pub fn (mut ts TestSession) test() { if ts.build_tools && dot_relative_file.ends_with('_test.v') { continue } + + // Skip OS-specific tests if we are not running that OS + // Special case for android_outside_termux because of its + // underscores + if file.ends_with('_android_outside_termux_test.v') { + if !testing.host_os.is_target_of('android_outside_termux') { + remaining_files << dot_relative_file + ts.skip_files << file + continue + } + } + os_target := file.all_before_last('_test.v').all_after_last('_') + if !testing.host_os.is_target_of(os_target) { + remaining_files << dot_relative_file + ts.skip_files << file + continue + } remaining_files << dot_relative_file } remaining_files = vtest.filter_vtest_only(remaining_files, fix_slashes: false) diff --git a/cmd/tools/vtest-self.v b/cmd/tools/vtest-self.v index a8a6d29670b084..bc8c8e479d5bee 100644 --- a/cmd/tools/vtest-self.v +++ b/cmd/tools/vtest-self.v @@ -94,10 +94,6 @@ const skip_test_files = [ 'vlib/db/pg/pg_orm_test.v', // pg not installed 'vlib/db/pg/pg_test.v', // pg not installed 'vlib/db/pg/pg_double_test.v', // pg not installed - 'vlib/v/tests/filtering_android_outside_termux_test.v', // platform filtering not baked into v test-self - 'vlib/v/tests/filtering_macos_test.v', // platform filtering not baked into v test-self - 'vlib/v/tests/filtering_nix_test.v', // platform filtering not baked into v test-self - 'vlib/v/tests/filtering_windows_test.v', // platform filtering not baked into v test-self ] // These tests are too slow to be run in the CI on each PR/commit // in the sanitized modes: diff --git a/cmd/tools/vtest.v b/cmd/tools/vtest.v index 77f475fbca4558..868fe9765f1572 100644 --- a/cmd/tools/vtest.v +++ b/cmd/tools/vtest.v @@ -5,8 +5,6 @@ import os.cmdline import testing import v.pref -const host_os = pref.get_host_os() - struct Context { mut: verbose bool @@ -132,18 +130,6 @@ enum ShouldTestStatus { } fn (mut ctx Context) should_test(path string, backend string) ShouldTestStatus { - // Skip OS-specific tests if we are not running that OS - // Special case for android_outside_termux because of its - // underscores - if path.ends_with('_android_outside_termux_test.v') { - if !host_os.is_target_of('android_outside_termux') { - return .skip - } - } - os_target := path.all_before_last('_test.v').all_after_last('_') - if !host_os.is_target_of(os_target) { - return .skip - } if path.ends_with('mysql_orm_test.v') { testing.find_started_process('mysqld') or { return .skip } } diff --git a/vlib/v/tests/filtering_android_outside_termux_test.v b/vlib/v/tests/filtering_tests/filtering_android_outside_termux_test.v similarity index 100% rename from vlib/v/tests/filtering_android_outside_termux_test.v rename to vlib/v/tests/filtering_tests/filtering_android_outside_termux_test.v diff --git a/vlib/v/tests/filtering_macos_test.v b/vlib/v/tests/filtering_tests/filtering_macos_test.v similarity index 100% rename from vlib/v/tests/filtering_macos_test.v rename to vlib/v/tests/filtering_tests/filtering_macos_test.v diff --git a/vlib/v/tests/filtering_nix_test.v b/vlib/v/tests/filtering_tests/filtering_nix_test.v similarity index 100% rename from vlib/v/tests/filtering_nix_test.v rename to vlib/v/tests/filtering_tests/filtering_nix_test.v diff --git a/vlib/v/tests/filtering_windows_test.v b/vlib/v/tests/filtering_tests/filtering_windows_test.v similarity index 100% rename from vlib/v/tests/filtering_windows_test.v rename to vlib/v/tests/filtering_tests/filtering_windows_test.v