Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
Ejemplo n.º 4
0
        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}");
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public static ILitCommand Parse(string line, LitTestConfiguration config)
 {
     return(ParseArguments(ILitCommand.Tokenize(line), config));
 }
Ejemplo n.º 7
0
 public static LitCommandWithRedirection Parse(string[] tokens, LitTestConfiguration config)
 {
     var    commandSymbol   = tokens[0];
     var    argumentsList   = tokens[1..].ToList();
Ejemplo n.º 8
0
        public ILitCommand ToShellCommand(LitTestConfiguration config)
        {
            var shellArguments = new[] { assembly.Location }.Concat(arguments);

            return(new ShellLitCommand(config, "dotnet", shellArguments, config.PassthroughEnvironmentVariables));
        }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 10
0
        public static UnsupportedCommand Parse(string line, LitTestConfiguration config)
        {
            var features = line.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim());

            return(new UnsupportedCommand(features));
        }