瀏覽代碼

Add -help to CI tests.

Jeroen van Rijn 3 年之前
父節點
當前提交
bb9165edd2
共有 2 個文件被更改,包括 19 次插入11 次删除
  1. 10 2
      src/main.cpp
  2. 9 9
      tests/core/Makefile

+ 10 - 2
src/main.cpp

@@ -2550,6 +2550,7 @@ int main(int arg_count, char const **arg_ptr) {
 	String command = args[1];
 	String command = args[1];
 	String init_filename = {};
 	String init_filename = {};
 	String run_args_string = {};
 	String run_args_string = {};
+	isize  last_non_run_arg = args.count;
 
 
 	bool run_output = false;
 	bool run_output = false;
 	if (command == "run" || command == "test") {
 	if (command == "run" || command == "test") {
@@ -2565,7 +2566,6 @@ int main(int arg_count, char const **arg_ptr) {
 		Array<String> run_args = array_make<String>(heap_allocator(), 0, arg_count);
 		Array<String> run_args = array_make<String>(heap_allocator(), 0, arg_count);
 		defer (array_free(&run_args));
 		defer (array_free(&run_args));
 
 
-		isize last_non_run_arg = args.count;
 		for_array(i, args) {
 		for_array(i, args) {
 			if (args[i] == "--") {
 			if (args[i] == "--") {
 				last_non_run_arg = i;
 				last_non_run_arg = i;
@@ -2675,7 +2675,15 @@ int main(int arg_count, char const **arg_ptr) {
 		// The command must be build, run, test, check, or another that takes a directory or filename.
 		// The command must be build, run, test, check, or another that takes a directory or filename.
 		if (!path_is_directory(init_filename)) {
 		if (!path_is_directory(init_filename)) {
 			// Input package is a filename. We allow this only if `-file` was given, otherwise we exit with an error message.
 			// Input package is a filename. We allow this only if `-file` was given, otherwise we exit with an error message.
-			if (!(args.count > 3 && args[3] == "-file")) {
+			bool single_file_package = false;
+			for_array(i, args) {
+				if (i >= 3 && i <= last_non_run_arg && args[i] == "-file") {
+					single_file_package = true;
+					break;
+				}
+			}
+
+			if (!single_file_package) {
 				gb_printf_err("ERROR: `%.*s %.*s` takes a package as its first argument.\n", LIT(args[0]), LIT(command));
 				gb_printf_err("ERROR: `%.*s %.*s` takes a package as its first argument.\n", LIT(args[0]), LIT(command));
 				gb_printf_err("Did you mean `%.*s %.*s %.*s -file`?\n", LIT(args[0]), LIT(command), LIT(init_filename));
 				gb_printf_err("Did you mean `%.*s %.*s %.*s -file`?\n", LIT(args[0]), LIT(command), LIT(init_filename));
 				gb_printf_err("The `-file` flag tells it to treat a file as a self-contained package.\n");
 				gb_printf_err("The `-file` flag tells it to treat a file as a self-contained package.\n");

+ 9 - 9
tests/core/Makefile

@@ -8,19 +8,19 @@ download_test_assets:
 	$(PYTHON) download_assets.py
 	$(PYTHON) download_assets.py
 
 
 image_test:
 image_test:
-	$(ODIN) run image/test_core_image.odin
+	$(ODIN) run image/test_core_image.odin -file
 
 
 compress_test:
 compress_test:
-	$(ODIN) run compress/test_core_compress.odin
+	$(ODIN) run compress/test_core_compress.odin -file
 
 
 strings_test:
 strings_test:
-	$(ODIN) run strings/test_core_strings.odin
+	$(ODIN) run strings/test_core_strings.odin -file
 
 
 hash_test:
 hash_test:
 	$(ODIN) run hash -out=test_hash -o:speed -no-bounds-check
 	$(ODIN) run hash -out=test_hash -o:speed -no-bounds-check
 
 
 crypto_test:
 crypto_test:
-	$(ODIN) run crypto -out=crypto_hash -o:speed -no-bounds-check
+	$(ODIN) run crypto -out=test_crypto_hash -o:speed -no-bounds-check
 
 
 noise_test:
 noise_test:
 	$(ODIN) run math/noise -out=test_noise
 	$(ODIN) run math/noise -out=test_noise
@@ -31,16 +31,16 @@ encoding_test:
 	$(ODIN) run encoding/varint -out=test_varint
 	$(ODIN) run encoding/varint -out=test_varint
 
 
 math_test:
 math_test:
-	$(ODIN) run math/test_core_math.odin -out=test_core_math -collection:tests=..
+	$(ODIN) run math/test_core_math.odin -out=test_core_math -file -collection:tests=..
 
 
 linalg_glsl_math_test:
 linalg_glsl_math_test:
-	$(ODIN) run math/linalg/glsl/test_linalg_glsl_math.odin -out=test_linalg_glsl_math -collection:tests=..
+	$(ODIN) run math/linalg/glsl/test_linalg_glsl_math.odin -file -out=test_linalg_glsl_math -collection:tests=..
 
 
 filepath_test:
 filepath_test:
-	$(ODIN) run path/filepath/test_core_filepath.odin -out=test_core_filepath -collection:tests=..
+	$(ODIN) run path/filepath/test_core_filepath.odin -file -out=test_core_filepath -collection:tests=..
 
 
 reflect_test:
 reflect_test:
-	$(ODIN) run reflect/test_core_reflect.odin -out=test_core_reflect -collection:tests=..
+	$(ODIN) run reflect/test_core_reflect.odin -file -out=test_core_reflect -collection:tests=..
 
 
 os_exit_test:
 os_exit_test:
-	$(ODIN) run os/test_core_os_exit.odin -out=test_core_os_exit && exit 1 || exit 0
+	$(ODIN) run os/test_core_os_exit.odin -file -out=test_core_os_exit && exit 1 || exit 0