aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/v/util/vtest/vtest.v
diff options
context:
space:
mode:
Diffstat (limited to 'v_windows/v/vlib/v/util/vtest/vtest.v')
-rw-r--r--v_windows/v/vlib/v/util/vtest/vtest.v37
1 files changed, 37 insertions, 0 deletions
diff --git a/v_windows/v/vlib/v/util/vtest/vtest.v b/v_windows/v/vlib/v/util/vtest/vtest.v
new file mode 100644
index 0000000..948cf41
--- /dev/null
+++ b/v_windows/v/vlib/v/util/vtest/vtest.v
@@ -0,0 +1,37 @@
+module vtest
+
+import os
+
+pub struct FilterVTestConfig {
+ basepath string
+ fix_slashes bool = true
+}
+
+// if VTEST_ONLY env var is set, returns tests that match the query
+pub fn filter_vtest_only(paths []string, config FilterVTestConfig) []string {
+ mut res := []string{}
+ patterns := os.getenv('VTEST_ONLY').split(',')
+ for relative_path in paths {
+ mut file := relative_path
+ if config.basepath.len > 0 {
+ file = os.join_path(config.basepath, file)
+ }
+ if config.fix_slashes {
+ file = file.replace('\\', '/')
+ }
+ if patterns.len != 0 {
+ mut found := 0
+ for okpat in patterns {
+ if file.contains(okpat) {
+ found++
+ break
+ }
+ }
+ if found == 0 {
+ continue
+ }
+ }
+ res << file
+ }
+ return res
+}