Make testing recursive
This commit is contained in:
parent
39521fbb19
commit
049a96191c
50
Program.cs
50
Program.cs
@ -13,42 +13,54 @@ public class Program
|
|||||||
break;
|
break;
|
||||||
case "run":
|
case "run":
|
||||||
{
|
{
|
||||||
Run(args[1]);
|
Run(args[1], true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void Run(string file)
|
public static void Run(string file, bool debug)
|
||||||
{
|
{
|
||||||
Token[] tokens = new Tokenizer().Tokenize(File.ReadAllText(file));
|
Token[] tokens = new Tokenizer().Tokenize(File.ReadAllText(file));
|
||||||
|
if(debug)
|
||||||
|
{
|
||||||
|
|
||||||
foreach(Token token in tokens)
|
foreach(Token token in tokens)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{token.region}: {token.type} {{{token.data}}}");
|
Console.WriteLine($"{token.region}: {token.type} {{{token.data}}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
static readonly Dictionary<string, string> failedFiles = [];
|
||||||
public static void Test(string directory)
|
public static void Test(string directory)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> failedFiles = [];
|
TestRecursive(directory);
|
||||||
foreach(string file in Directory.EnumerateFiles(directory))
|
|
||||||
{
|
|
||||||
if(file.EndsWith(".lua"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Run(file);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{file}: {e.Message}");
|
|
||||||
failedFiles.Add(file, e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Console.WriteLine("===FAILED===");
|
Console.WriteLine("===FAILED===");
|
||||||
foreach(KeyValuePair<string, string> entry in failedFiles)
|
foreach(KeyValuePair<string, string> entry in failedFiles)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{entry.Key}: {entry.Value}");
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user