finished settings for run_tests
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 4 Dec 2021 03:30:22 +0000 (21:30 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 4 Dec 2021 03:30:22 +0000 (21:30 -0600)
.github/workflows/onyx-build.yml
core/container/iter.onyx
scripts/run_tests.onyx

index 7152404e22068a940e34abfc22ab0aef756f3baf..336bc14f82ac93c1e157dbfceb172a0c378f4235 100644 (file)
@@ -20,4 +20,4 @@ jobs:
     - name: build onyx
       run: ./build.sh
     - name: run tests
-      run: ./bin/onyx run scripts/run_tests.onyx -- --threads=0
+      run: ./bin/onyx run scripts/run_tests.onyx
index 698b40bb6a89f4f6eaf5e4851ba910cbf9691d65..63e0e73488a52a732e67c03bbc49a4aa476d2883 100644 (file)
@@ -77,9 +77,9 @@ map :: (it: Iterator($T), transform: (T) -> $R) -> Iterator(R) {
     };
 }
 
-take_one :: (it: Iterator($T)) -> (T, bool) {
+take_one :: (it: Iterator($T), no_close := false) -> (T, bool) {
     ret, cont := it.next(it.data);
-    if !cont do it.close(it.data);
+    if !cont && !no_close do it.close(it.data);
     return ret, cont;
 }
 
index 1adad07ba7908a72c3ea7af633f617fa4cd9d75c..b17e81dade4b8b25b69c881640ff6e4b74d68eb5 100644 (file)
@@ -69,7 +69,7 @@ print_color :: (color: Color, format: str, args: ..any) {
     buffer: [2048] u8;
     output := conv.str_format_va(buffer, format, args);
 
-    #if runtime.OS == runtime.OS_Linux {
+    if runtime.OS == runtime.OS_Linux && !settings.no_color {
         color_code: str;
         switch color {
             case .Red do color_code = "\x1b[91m";
@@ -153,7 +153,7 @@ test_cases :: (cases) => {
 
 // The executable to use when compiling
 onyx_cmd: str;
-
+settings := Settings.{};
 
 Settings :: struct {
     ["--debug", "-d"]
@@ -169,16 +169,15 @@ Settings :: struct {
     test_folder := "./tests";
 }
 
-// #export "args_parse" args_parse
-args_parse :: (c_args: [] cstr, output: ^$ArgType) -> bool {
+args_parse :: (c_args: [] cstr, output: ^Settings) -> bool {
     arg_iter := iter.as_iterator(c_args)
-            |> iter.map((x) => string.from_cstr(*x));
+             |> iter.map((x) => string.from_cstr(*x));
 
     use type_info;
 
-    arg_type := cast(^Type_Info_Struct) get_type_info(ArgType);
+    arg_type := cast(^Type_Info_Struct) get_type_info(typeof *output);
     if arg_type.kind != .Struct do return false;
-    
+
     for #no_close arg: arg_iter {
         for ^member: arg_type.members {
             for ^tag: member.tags {
@@ -201,8 +200,15 @@ args_parse :: (c_args: [] cstr, output: ^$ArgType) -> bool {
                         *(cast(^i32) (cast(^u8) output + member.offset)) = ~~value;
                     }
 
+                    case str {
+                        value, success := iter.take_one(arg_iter);
+                        if !success do return false;
+
+                        *(cast(^str) (cast(^u8) output + member.offset)) = value;
+                    }
+
                     case #default {
-                        printf("Unsupported argument type.");
+                        println("Unsupported argument type.");
                         return false;
                     }
                 }
@@ -212,16 +218,13 @@ args_parse :: (c_args: [] cstr, output: ^$ArgType) -> bool {
 
     // This has to be done explicitly beacuse the iter.take_one function
     // can close the iterator if it runs out during the taking.
-    arg_iter->close();
+    arg_iter.close(arg_iter.data);
     return true;
 }
 
 main :: (args) => {
-    settings := Settings.{};
     args_parse(args, ^settings);
-    println(settings);
-
-    test_folder := "./tests";
+    printf("Using {p*}\n", ^settings);
 
     switch runtime.OS {
         case runtime.OS_Linux {
@@ -232,7 +235,7 @@ main :: (args) => {
     }
 
     cases := array.make(Test_Case, capacity=256);
-    find_onyx_files(test_folder, ^cases);
+    find_onyx_files(settings.test_folder, ^cases);
 
     thread_count := settings.threads;
     case_iterator := distributor(cases);