public void ArgStringPipeTest() { ShellParser shellParser = MakeParser("\"12345 | echo asdf\""); ArgContext context = shellParser.arg(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); result.IsArg.Should().BeTrue(); result.ArgValue.Should().Be("12345 | echo asdf"); }
public void ArgStringSingleQuoteTest() { ShellParser shellParser = MakeParser("'string arg'"); ArgContext context = shellParser.arg(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); result.IsArg.Should().BeTrue(); result.ArgValue.Should().Be("string arg"); }
public void ArgWordTest() { ShellParser shellParser = MakeParser("wordarg"); ArgContext context = shellParser.arg(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); result.IsArg.Should().BeTrue(); result.ArgValue.Should().Be("wordarg"); }
public void CmdTest() { ShellParser shellParser = MakeParser("cmdword"); CmdContext context = shellParser.cmd(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); result.IsCmd.Should().BeTrue(); result.CmdValue.Should().Be("cmdword"); }
public void SimpleCommandNoArgsTest() { ShellParser shellParser = MakeParser("git"); SimpleCommandContext context = shellParser.simpleCommand(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); SimpleCommand actualCommand = result.SimpleCommandValue; result.IsSimpleCommand.Should().BeTrue(); actualCommand.Command.Should().Be("git"); actualCommand.Arguments.Should().BeEmpty(); }
public void PipeListOneCommandTest() { ShellParser shellParser = MakeParser("git reset --hard"); PipeListContext context = shellParser.pipeList(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); List <SimpleCommand> actualPipeList = result.PipeListValue; result.IsPipeList.Should().BeTrue(); actualPipeList.Should().HaveCount(1); actualPipeList[0].ToString().Should().Be("git reset --hard"); }
public void ShellCommandOnlyPipesTest() { ShellParser shellParser = MakeParser("git reset --hard | echo"); ShellCommandContext context = shellParser.shellCommand(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); ShellCommand shellCommand = result.ShellCommandValue; result.IsShellCommand.Should().BeTrue(); shellCommand.IsBackground.Should().BeFalse(); shellCommand.CommandList.Should().HaveCount(2); }
public void ArgListMixedArgsTest() { ShellParser shellParser = MakeParser("these are 'some args'"); ArgsContext context = shellParser.args(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); result.IsArgList.Should().BeTrue(); result.ArgListValue.Should().BeEquivalentTo(new List <string> { "these", "are", "some args" }, opts => opts.WithStrictOrdering()); }
public void ArgListOneWordTest() { ShellParser shellParser = MakeParser("wordarg"); ArgsContext context = shellParser.args(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); result.IsArgList.Should().BeTrue(); result.ArgListValue.Should().BeEquivalentTo(new List <string> { "wordarg" }, opts => opts.WithStrictOrdering()); }
public void ShellCommandSingleCommandTest() { ShellParser shellParser = MakeParser("git reset --hard"); ShellCommandContext context = shellParser.shellCommand(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); ShellCommand shellCommand = result.ShellCommandValue; result.IsShellCommand.Should().BeTrue(); shellCommand.IsBackground.Should().BeFalse(); shellCommand.CommandList.Should().HaveCount(1); shellCommand.CommandList[0].ToString().Should().Be("git reset --hard"); }
public void SimpleCommandWithArgsTest() { ShellParser shellParser = MakeParser("git reset --hard"); SimpleCommandContext context = shellParser.simpleCommand(); ShellVisitor visitor = new ShellVisitor(); ParserResult result = visitor.Visit(context); SimpleCommand actualCommand = result.SimpleCommandValue; result.IsSimpleCommand.Should().BeTrue(); actualCommand.Command.Should().Be("git"); actualCommand.Arguments.Should().BeEquivalentTo(new List <string> { "reset", "--hard" }, opt => opt.WithStrictOrdering()); }