From 049a96191c6eeff5ce66bd8e971eb5a586f2ded1 Mon Sep 17 00:00:00 2001 From: 0x4261756D <38735823+0x4261756D@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:24:24 +0100 Subject: [PATCH] Make testing recursive --- Program.cs | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/Program.cs b/Program.cs index 95cbc73..f56d82b 100644 --- a/Program.cs +++ b/Program.cs @@ -13,42 +13,54 @@ public class Program break; case "run": { - Run(args[1]); + Run(args[1], true); } break; } } - public static void Run(string file) + public static void Run(string file, bool debug) { Token[] tokens = new Tokenizer().Tokenize(File.ReadAllText(file)); - foreach(Token token in tokens) + if(debug) { - Console.WriteLine($"{token.region}: {token.type} {{{token.data}}}"); - } - } - public static void Test(string directory) - { - Dictionary failedFiles = []; - foreach(string file in Directory.EnumerateFiles(directory)) - { - if(file.EndsWith(".lua")) + foreach(Token token in tokens) { - try - { - Run(file); - } - catch(Exception e) - { - Console.WriteLine($"{file}: {e.Message}"); - failedFiles.Add(file, e.Message); - } + Console.WriteLine($"{token.region}: {token.type} {{{token.data}}}"); } } + } + static readonly Dictionary failedFiles = []; + public static void Test(string directory) + { + TestRecursive(directory); Console.WriteLine("===FAILED==="); foreach(KeyValuePair entry in failedFiles) { Console.WriteLine($"{entry.Key}: {entry.Value}"); } } + + public static void TestRecursive(string directory) + { + foreach(string file in Directory.EnumerateFiles(directory)) + { + if(file.EndsWith(".lua")) + { + try + { + Run(file, false); + } + catch(Exception e) + { + Console.WriteLine($"{file}: {e}"); + failedFiles.Add(file, e.ToString()); + } + } + } + foreach(string dir in Directory.EnumerateDirectories(directory)) + { + TestRecursive(dir); + } + } }