| 542 | self.assertRaises(bashlex.errors.ParsingError, matcher.Matcher(cmd, s).match) |
| 543 | |
| 544 | def test_known_and_unknown_program(self): |
| 545 | cmd = "bar; foo arg >f; baz" |
| 546 | matchedresult = [ |
| 547 | [ |
| 548 | MR(3, 4, help_constants.OPERATORS[";"], ";"), |
| 549 | MR( |
| 550 | 13, |
| 551 | 15, |
| 552 | help_constants.REDIRECTION |
| 553 | + "\n\n" |
| 554 | + help_constants.REDIRECTION_KIND[">"], |
| 555 | ">f", |
| 556 | ), |
| 557 | MR(15, 16, help_constants.OPERATORS[";"], ";"), |
| 558 | ], |
| 559 | [MR(0, 3, "bar synopsis", "bar")], |
| 560 | [MR(5, 12, None, "foo arg")], |
| 561 | [MR(17, 20, "baz synopsis", "baz")], |
| 562 | ] |
| 563 | |
| 564 | groups = matcher.Matcher(cmd, s).match() |
| 565 | self.assertEqual(groups[0].results, matchedresult[0]) |
| 566 | self.assertEqual(groups[1].results, matchedresult[1]) |
| 567 | self.assertEqual(groups[2].results, matchedresult[2]) |
| 568 | |
| 569 | def test_pipe(self): |
| 570 | cmd = "bar | baz" |