def test_c_discovery_plugin_scan_exceptions():
    """Test that the C discovery plugin finds valid C source/header files."""
    cdp = CDiscoveryPlugin()
    package = Package("valid_package",
                      os.path.join(os.path.dirname(__file__), "valid_package"))
    exceptions = Exceptions(
        os.path.join(os.path.dirname(__file__), "exceptions.yaml"))
    cdp.scan(package, "level", exceptions)
    expected = [
        "test.c",
        "test.cpp",
        "test.cc",
        "test.cxx",
        "test.h",
        "test.hxx",
        "test.hpp",
    ]
    if cdp.file_command_exists():
        expected += ["oddextensioncpp.source", "oddextensionc.source"]
    # We have to add the path to each of the above
    expected_fullpath = [
        os.path.join(package.path, filename) for filename in expected
    ]
    # Neat trick to verify that two unordered lists are the same
    assert set(package["c_src"]) == set(expected_fullpath)
def test_c_discovery_plugin_no_file_cmd():
    """
    Test when file command does not exist.

    Test that files are not discovered with file command output if file
    command does not exist.
    """
    with modified_environ(PATH=""):
        cdp = CDiscoveryPlugin()
        package = Package(
            "valid_package",
            os.path.join(os.path.dirname(__file__), "valid_package"))
        cdp.scan(package, "level")
        expected = [
            "test.c",
            "test.cpp",
            "test.cc",
            "test.cxx",
            "test.h",
            "test.hxx",
            "test.hpp",
            os.path.join("ignore_this", "ignoreme.c"),
        ]
        # We have to add the path to each of the above...yuck
        expected_fullpath = [
            os.path.join(package.path, filename) for filename in expected
        ]
        # Neat trick to verify that two unordered lists are the same
        assert set(package["c_src"]) == set(expected_fullpath)
Exemplo n.º 3
0
def test_c_discovery_plugin_scan_invalid():
    """Test that the C discovery plugin doesn't find non-C files."""
    cdp = CDiscoveryPlugin()
    package = Package(
        'invalid_package',
        os.path.join(os.path.dirname(__file__), 'invalid_package'))
    cdp.scan(package, 'level')
    assert not package['c_src']
def test_c_discovery_plugin_scan_invalid():
    """Test that the C discovery plugin doesn't find non-C files."""
    cdp = CDiscoveryPlugin()
    package = Package(
        "invalid_package",
        os.path.join(os.path.dirname(__file__), "invalid_package"))
    cdp.scan(package, "level")
    assert not package["c_src"]
Exemplo n.º 5
0
def test_c_discovery_plugin_scan_valid():
    """Test that the C discovery plugin finds valid C source/header files."""
    cdp = CDiscoveryPlugin()
    package = Package('valid_package',
                      os.path.join(os.path.dirname(__file__), 'valid_package'))
    cdp.scan(package, 'level')
    expected = [
        'test.c', 'test.cpp', 'test.cc', 'test.cxx', 'test.h', 'test.hxx',
        'test.hpp'
    ]
    if cdp.file_command_exists():
        expected += ['oddextensioncpp.source', 'oddextensionc.source']
    # We have to add the path to each of the above...yuck
    expected_fullpath = [
        os.path.join(package.path, filename) for filename in expected
    ]
    # Neat trick to verify that two unordered lists are the same
    assert set(package['c_src']) == set(expected_fullpath)
Exemplo n.º 6
0
def test_c_discovery_plugin_no_file_cmd():
    """
    Test when file command does not exist.

    Test that files are not discovered with file command output if file
    command does not exist.
    """
    with modified_environ(PATH=''):
        cdp = CDiscoveryPlugin()
        package = Package(
            'valid_package',
            os.path.join(os.path.dirname(__file__), 'valid_package'))
        cdp.scan(package, 'level')
        expected = [
            'test.c', 'test.cpp', 'test.cc', 'test.cxx', 'test.h', 'test.hxx',
            'test.hpp',
            os.path.join('ignore_this', 'ignoreme.c')
        ]
        # We have to add the path to each of the above...yuck
        expected_fullpath = [
            os.path.join(package.path, filename) for filename in expected
        ]
        # Neat trick to verify that two unordered lists are the same
        assert set(package['c_src']) == set(expected_fullpath)