def test_cmdline_example():
    _test_cmdline(ps(
        '\n# a comment\nextract params.txt data/b.csv data/a.csv | sort -n | tail -n 3 > last.csv\n'
    ), [['extract', '', [rxc(r'p.+\.txt'), {'data/a.csv', 'data/b.csv'}]],
        ['sort', 'n'], ['tail', 'n:', [], {
            '-n': '3'
        }]],
                  'Use extract, sort, and tail with redirection.',
                  redirect_out=re.compile(r'.+\.csv'),
                  last_line_only=True)
Exemple #2
0
def test_debug_match_command():
    pattern = [['abc',   'l']]
    actual = 'wc -l'
    with pytest.raises(TF):
        _test_cmdline(ps(actual), pattern, debug='EXTRA MESSAGE')
Exemple #3
0
def test_overall_command_only_mismatch():
    with pytest.raises(TF):
        _test_cmdline(ps('a'), [['b']])
Exemple #4
0
def test_overall_pipeline():
    actual = 'wc -l a.txt b.txt "c.txt d.txt" | sort -n -r | head -n 3 > result.txt'
    pattern = [['wc',   'l', '+'],
	       ['sort', 'nr'],
	       ['head', 'n:', None, {'-n' : '3'}]]
    _test_cmdline(ps(actual), pattern, redirect=re.compile(r'.+\.txt'), incorrect_msg='Incorrect command line')
Exemple #5
0
def test_overall_command_only_match():
    _test_cmdline(ps('a'), [['a']])