Example #1
0
def test_multiple_commands_per_line_command_style():
    """Test the command_style option using the multiple_commands_oneline.txt build log.
    """
    cwd = getcwd()

    with input_file('multiple_commands_oneline.txt') as build_log:
        result = parse_build_log(
            build_log,
            proj_dir=cwd,
            exclude_files=[],
            command_style=True,
        )

    assert result.count == 2
    assert result.skipped == 0
    assert result.compdb == [
        {
            'command': 'g++ -c ./path/src/hein.cpp -o out.o',
            'directory': cwd,
            'file': './path/src/hein.cpp',
        },
        {
            'command': 'gcc -c -o main.o main.c',
            'directory': cwd,
            'file': 'main.c',
        }
    ]
Example #2
0
def test_automake_command():
    pwd = getcwd()
    with input_file('autotools_simple.txt') as build_log:
        result = parse_build_log(
            build_log,
            proj_dir=pwd,
            exclude_files=[])

    assert result.count == 1
    assert result.skipped == 0
    assert len(result.compdb) == 1
    assert result.compdb[0] == {
        'directory': pwd,
        'file': './main.c',
        'arguments': [
            'gcc',
            '-DPACKAGE_NAME="hello"',
            '-DPACKAGE_VERSION="1.0.0"',
            '-DSTDC_HEADERS=1',
            '-I.',
            '-I../../src/libhello',
            '-c',
            '-o', 'hello_world1-main.o',
            './main.c'
        ]
    }
Example #3
0
def assert_generate_is_true(outstream, overwrite):
    with input_file('multiple_commands_oneline.txt') as instream:
        assert generate(infile=instream,
                        outfile=outstream,
                        build_dir=os.getcwd(),
                        exclude_files=[],
                        overwrite=overwrite,
                        strict=False)
Example #4
0
def test_multiple_commands_per_line():
    pwd = getcwd()
    with input_file('multiple_commands_oneline.txt') as build_log:
        result = parse_build_log(build_log, proj_dir=pwd, exclude_files=[])

    assert result.count == 2
    assert result.skipped == 0
    assert len(result.compdb) == 2
    assert result.compdb[0] == {
        'directory': pwd,
        'file': './path/src/hein.cpp',
        'arguments': ['g++', '-c', './path/src/hein.cpp', '-o', 'out.o']
    }
Example #5
0
def test_load_compdb_path_file_exists(caplog):
    try:
        orig_pwd = os.getcwd()
        os.chdir(data_dir)
        expected_compdb = [{
            'file': 'foo.cpp',
            'directory': 'data',
            'arguments': ['g++', 'foo.cpp', '-o', 'foo.o']
        }]
        with input_file('compile_commands.json') as outfile:
            assert load_json_compdb(outfile) == expected_compdb
            assert (
                'Loaded compilation database with 1 entries from compile_commands.json'
                in caplog.text)
    finally:
        os.chdir(orig_pwd)