From 55fdae77d5402e41fed1fd0d2fc74b1ae8d444ce Mon Sep 17 00:00:00 2001
From: Delyan Angelov <delian66@gmail.com>
Date: Tue, 25 Aug 2020 18:46:33 +0300
Subject: [PATCH] tests: add .vv support for `v vet` too, and simplify
 vet_test.v

---
 cmd/tools/vvet.v                        | 8 ++++++--
 vlib/v/vet/tests/array_init_one_val.out | 2 +-
 vlib/v/vet/tests/indent_with_space.out  | 2 +-
 vlib/v/vet/tests/parens_space_a.out     | 2 +-
 vlib/v/vet/tests/parens_space_b.out     | 2 +-
 vlib/v/vet/vet_test.v                   | 8 ++------
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/cmd/tools/vvet.v b/cmd/tools/vvet.v
index 057c878e8c..303e4be4bf 100644
--- a/cmd/tools/vvet.v
+++ b/cmd/tools/vvet.v
@@ -37,11 +37,15 @@ fn main() {
 			eprintln('skipping $path')
 			continue
 		}
-		if path.ends_with('.v') {
+		if path.ends_with('.v') || path.ends_with('.vv') {
 			vet_options.vet_file(path)
 		} else if os.is_dir(path) {
 			vet_options.vprintln("vetting folder '$path'...")
-			files := os.walk_ext(path, '.v')
+			vfiles := os.walk_ext(path, '.v')
+			vvfiles := os.walk_ext(path, '.vv')
+			mut files := []string{}
+			files << vfiles
+			files << vvfiles
 			for file in files {
 				if file.ends_with('_test.v') || file.contains('/tests/') { // TODO copy pasta
 					continue
diff --git a/vlib/v/vet/tests/array_init_one_val.out b/vlib/v/vet/tests/array_init_one_val.out
index 32b934cffb..e04de3162f 100644
--- a/vlib/v/vet/tests/array_init_one_val.out
+++ b/vlib/v/vet/tests/array_init_one_val.out
@@ -1,2 +1,2 @@
-vlib/v/vet/tests/array_init_one_val.v:2: Use `var == value` instead of `var in [value]`
+vlib/v/vet/tests/array_init_one_val.vv:2: Use `var == value` instead of `var in [value]`
 NB: You can run `v fmt -w file.v` to fix these automatically
diff --git a/vlib/v/vet/tests/indent_with_space.out b/vlib/v/vet/tests/indent_with_space.out
index 2eceb1d9b3..2087bcbe99 100644
--- a/vlib/v/vet/tests/indent_with_space.out
+++ b/vlib/v/vet/tests/indent_with_space.out
@@ -1,2 +1,2 @@
-vlib/v/vet/tests/indent_with_space.v:2: Looks like you are using spaces for indentation.
+vlib/v/vet/tests/indent_with_space.vv:2: Looks like you are using spaces for indentation.
 NB: You can run `v fmt -w file.v` to fix these automatically
diff --git a/vlib/v/vet/tests/parens_space_a.out b/vlib/v/vet/tests/parens_space_a.out
index f476657297..213a41e460 100644
--- a/vlib/v/vet/tests/parens_space_a.out
+++ b/vlib/v/vet/tests/parens_space_a.out
@@ -1,2 +1,2 @@
-vlib/v/vet/tests/parens_space_a.v:1: Looks like you are adding a space after `(`
+vlib/v/vet/tests/parens_space_a.vv:1: Looks like you are adding a space after `(`
 NB: You can run `v fmt -w file.v` to fix these automatically
diff --git a/vlib/v/vet/tests/parens_space_b.out b/vlib/v/vet/tests/parens_space_b.out
index a395988766..d96fbffd13 100644
--- a/vlib/v/vet/tests/parens_space_b.out
+++ b/vlib/v/vet/tests/parens_space_b.out
@@ -1,2 +1,2 @@
-vlib/v/vet/tests/parens_space_b.v:1: Looks like you are adding a space before `)`
+vlib/v/vet/tests/parens_space_b.vv:1: Looks like you are adding a space before `)`
 NB: You can run `v fmt -w file.v` to fix these automatically
diff --git a/vlib/v/vet/vet_test.v b/vlib/v/vet/vet_test.v
index 79a8f1c85c..89f0a108cc 100644
--- a/vlib/v/vet/vet_test.v
+++ b/vlib/v/vet/vet_test.v
@@ -27,15 +27,12 @@ fn check_path(vexe, dir string, tests []string) int {
 		basepath: dir
 	})
 	for path in paths {
-		program := path.replace('.vv', '.v')
+		program := path
 		print(path + ' ')
-		os.cp(path, program) or {
-			panic(err)
-		}
 		res := os.exec('$vexe vet $program') or {
 			panic(err)
 		}
-		mut expected := os.read_file(program.replace('.v', '') + '.out') or {
+		mut expected := os.read_file(program.replace('.vv', '') + '.out') or {
 			panic(err)
 		}
 		expected = clean_line_endings(expected)
@@ -52,7 +49,6 @@ fn check_path(vexe, dir string, tests []string) int {
 			nb_fail++
 		} else {
 			println(term.green('OK'))
-			os.rm(program)
 		}
 	}
 	return nb_fail