static LitTests() { var substitutions = new Dictionary <string, string> { { "%diff", "diff" }, { "%binaryDir", "." }, { "%z3", Path.Join("z3", "bin", "z3") }, { "%refmanexamples", Path.Join("TestFiles", "LitTests", "LitTest", "refman", "examples") } }; var commands = new Dictionary <string, Func <IEnumerable <string>, LitTestConfiguration, ILitCommand> > { { "%baredafny", (args, config) => MainWithArguments(DafnyDriverAssembly, args, config, InvokeMainMethodsDirectly) }, { "%dafny", (args, config) => MainWithArguments(DafnyDriverAssembly, DefaultDafnyArguments.Concat(args), config, InvokeMainMethodsDirectly) }, { "%server", (args, config) => MainWithArguments(DafnyServerAssembly, args, config, InvokeMainMethodsDirectly) } }; var passthroughEnvironmentVariables = new[] { "PATH", "HOME" }; string[] features; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { features = new[] { "ubuntu", "posix" }; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { features = new[] { "windows" }; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { features = new[] { "macosx", "posix" }; } else { throw new Exception($"Unsupported OS: {RuntimeInformation.OSDescription}"); } var dafnyReleaseDir = Environment.GetEnvironmentVariable("DAFNY_RELEASE"); if (dafnyReleaseDir != null) { commands["%baredafny"] = (args, config) => new ShellLitCommand(config, Path.Join(dafnyReleaseDir, "dafny"), args, config.PassthroughEnvironmentVariables); commands["%dafny"] = (args, config) => new ShellLitCommand(config, Path.Join(dafnyReleaseDir, "dafny"), DefaultDafnyArguments.Concat(args), config.PassthroughEnvironmentVariables); commands["%server"] = (args, config) => new ShellLitCommand(config, Path.Join(dafnyReleaseDir, "DafnyServer"), args, config.PassthroughEnvironmentVariables); substitutions["%z3"] = Path.Join(dafnyReleaseDir, "z3", "bin", "z3"); } Config = new LitTestConfiguration(substitutions, commands, features, passthroughEnvironmentVariables); }
private static ILitCommand MainWithArguments(Assembly assembly, IEnumerable <string> arguments, LitTestConfiguration config, bool invokeDirectly) { return(MainMethodLitCommand.Parse(assembly, arguments, config, invokeDirectly)); }