public ShellLitCommand(LitTestConfiguration config, string shellCommand, IEnumerable <string> arguments, IEnumerable <string> passthroughEnvironmentVariables) { this.config = config; this.shellCommand = shellCommand; this.arguments = arguments.ToArray(); this.passthroughEnvironmentVariables = passthroughEnvironmentVariables.ToArray(); }
public static LitTestCase Read(string filePath, LitTestConfiguration config) { ILitCommand[] commands = File.ReadAllLines(filePath) .Select(line => ILitCommand.Parse(line, config)) .Where(c => c != null) .Select(e => e !) .ToArray(); if (commands.Length == 0) { throw new ArgumentException($"No lit commands found in test file: {filePath}"); } var xfail = commands.Any(c => c is XFailCommand); foreach (var unsupported in commands.OfType <UnsupportedCommand>()) { foreach (var feature in config.Features) { if (unsupported.Features.Contains(feature)) { throw new SkipException($"Test case not supported: {feature}"); } } } return(new LitTestCase(filePath, commands, xfail)); }
private static ILitCommand ParseArguments(string[] tokens, LitTestConfiguration config) { // Just supporting || for now since it's a precise way to ignore an exit code var seqOperatorIndex = Array.IndexOf(tokens, "||"); if (seqOperatorIndex >= 0) { var lhs = LitCommandWithRedirection.Parse(tokens[0..seqOperatorIndex], config);
public static ILitCommand Parse(string line, LitTestConfiguration config) { // Only supporting * for now if (line.Equals("*")) { return(new XFailCommand()); } throw new ArgumentException($"Unrecognized arguments to XFAIL: {line}"); }
public static void Run(string filePath, LitTestConfiguration config, ITestOutputHelper outputHelper) { string fileName = Path.GetFileName(filePath); string?directory = Path.GetDirectoryName(filePath); if (directory == null) { throw new ArgumentException("Couldn't get directory name for path: {}"); } string fullDirectoryPath = Path.GetFullPath(directory); config = config.WithSubstitutions(new Dictionary <string, string> { { "%s", filePath }, { "%S", fullDirectoryPath }, { "%t", Path.Join(fullDirectoryPath, "Output", $"{fileName}.tmp") } }); var testCase = Read(filePath, config); testCase.Execute(outputHelper); }
public static ILitCommand Parse(string line, LitTestConfiguration config) { return(ParseArguments(ILitCommand.Tokenize(line), config)); }
public static LitCommandWithRedirection Parse(string[] tokens, LitTestConfiguration config) { var commandSymbol = tokens[0]; var argumentsList = tokens[1..].ToList();
public ILitCommand ToShellCommand(LitTestConfiguration config) { var shellArguments = new[] { assembly.Location }.Concat(arguments); return(new ShellLitCommand(config, "dotnet", shellArguments, config.PassthroughEnvironmentVariables)); }
public static ILitCommand Parse(Assembly assembly, IEnumerable <string> arguments, LitTestConfiguration config, bool invokeDirectly) { var result = new MainMethodLitCommand(assembly, arguments.ToArray()); return(invokeDirectly ? result : result.ToShellCommand(config)); }
public static UnsupportedCommand Parse(string line, LitTestConfiguration config) { var features = line.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()); return(new UnsupportedCommand(features)); }