# Path: snaked/plugins/external_tools/parser.py
# def parse(text):
#     ctx = Context()
#     func = search_tool
#     for i, l in enumerate(text.splitlines()):
#         ctx.lineno = i + 1
#         while True:
#             func, move_next = func(ctx, l)
#             if move_next: break
# 
#     func(ctx, 'end')
# 
#     return ctx.tools
# 
# class ParseException(Exception): pass


import pytest
from snaked.plugins.external_tools.parser import parse, ParseException
    assert t.script == "    cd doc\n\n    make clean\n"

    t = tools[2]
    assert t.name == 'run'
    assert t.context == ['python', 'python-script']
    assert t.input == 'from-buffer'
    assert t.output == 'to-console'
    assert t.script == "    python $FILENAME"

def test_invalid_tool_name_parsing():
    data = """
tool sss
    cd wow
    """

    try:
        parse(data)
        pytest.fail('Must raise ParseException')
    except ParseException, e:
        assert 'tool name' in str(e)

def test_garbage_in_tool_definition():
    data = """
tool "sss" for sss
    cd wow
    """

    try:
        parse(data)
        pytest.fail('Must raise ParseException')

# Path: snaked/plugins/external_tools/parser.py
# def parse(text):
#     ctx = Context()
#     func = search_tool
#     for i, l in enumerate(text.splitlines()):
#         ctx.lineno = i + 1
#         while True:
#             func, move_next = func(ctx, l)
#             if move_next: break
# 
#     func(ctx, 'end')
# 
#     return ctx.tools
# 
# class ParseException(Exception): pass


# Path: tests/test_external_tool.py
import pytest
from snaked.plugins.external_tools.parser import parse, ParseException

    assert t.script == "    cd doc\n\n    make clean\n"

    t = tools[2]
    assert t.name == 'run'
    assert t.context == ['python', 'python-script']
    assert t.input == 'from-buffer'
    assert t.output == 'to-console'
    assert t.script == "    python $FILENAME"

def test_invalid_tool_name_parsing():
    data = """
tool sss
    cd wow
    """

    try:
        parse(data)
        pytest.fail('Must raise ParseException')
    except ParseException, e:
        assert 'tool name' in str(e)

def test_garbage_in_tool_definition():
    data = """
tool "sss" for sss
    cd wow
    """

    try:
        parse(data)
        pytest.fail('Must raise ParseException')

    except ParseException, e: