def runTest(self):
        node = json.loads(covdata)
        result = CoverageHelper.get_flattened_names(node, prefix="")

        expected_names = [
            'topdir1', 'topdir1/subdir2', 'topdir1/subdir2/file3.c',
            'topdir1/subdir1/file2.c', 'topdir1/subdir1',
            'topdir1/subdir1/file1.c', 'topdir2', 'topdir2/subdir1',
            'topdir2/subdir1/file1.c'
        ]

        self.assertEqual(result, set(expected_names))
def test_CoverageHelperApplyDirectivesMakeEmpty():
    node = json.loads(covdata)

    # Check that making the set entirely empty doesn't crash things (tsmith mode)
    directives = ["-:**"]

    CoverageHelper.apply_include_exclude_directives(node, directives)

    result = CoverageHelper.get_flattened_names(node, prefix="")

    expected_names = []

    assert result == set(expected_names)
    def runTest(self):
        node = json.loads(covdata)

        # Check that making the set entirely empty doesn't crash things (tsmith mode)
        directives = ["-:**"]

        CoverageHelper.apply_include_exclude_directives(node, directives)

        result = CoverageHelper.get_flattened_names(node, prefix="")

        expected_names = []

        self.assertEqual(result, set(expected_names))
    def runTest(self):
        node = json.loads(covdata)

        # Check that excluding all paths works (specialized case)
        directives = ["-:**", "+:topdir2/subdir1/**"]

        CoverageHelper.apply_include_exclude_directives(node, directives)

        result = CoverageHelper.get_flattened_names(node, prefix="")

        expected_names = [
            'topdir2', 'topdir2/subdir1', 'topdir2/subdir1/file1.c'
        ]

        self.assertEqual(result, set(expected_names))
    def runTest(self):
        node = json.loads(covdata)

        # Check that any empty childs are pruned (empty childs are not useful)
        directives = ["-:topdir1/subdir1/**", "-:topdir1/subdir2/**"]

        CoverageHelper.apply_include_exclude_directives(node, directives)

        result = CoverageHelper.get_flattened_names(node, prefix="")

        expected_names = [
            'topdir2', 'topdir2/subdir1', 'topdir2/subdir1/file1.c'
        ]

        self.assertEqual(result, set(expected_names))
def test_CoverageHelperApplyDirectivesExcludeAll():
    node = json.loads(covdata)

    # Check that excluding all paths works (specialized case)
    directives = ["-:**", "+:topdir2/subdir1/**"]

    CoverageHelper.apply_include_exclude_directives(node, directives)

    result = CoverageHelper.get_flattened_names(node, prefix="")

    expected_names = [
        'topdir2',
        'topdir2/subdir1',
        'topdir2/subdir1/file1.c'
    ]

    assert result == set(expected_names)
def test_CoverageHelperFlattenNames():
    node = json.loads(covdata)
    result = CoverageHelper.get_flattened_names(node, prefix="")

    expected_names = [
        'topdir1',
        'topdir1/subdir2',
        'topdir1/subdir2/file3.c',
        'topdir1/subdir1/file2.c',
        'topdir1/subdir1',
        'topdir1/subdir1/file1.c',
        'topdir2',
        'topdir2/subdir1',
        'topdir2/subdir1/file1.c'
    ]

    assert result == set(expected_names)
    def runTest(self):
        node = json.loads(covdata)

        # Check that mixed directives work properly (exclude multiple paths, include some back)
        directives = [
            "-:topdir1/subdir1/**", "+:topdir1/subdir?/file1.c",
            "+:topdir1/subdir?/file3.c", "-:topdir1/subdir2/**"
        ]

        CoverageHelper.apply_include_exclude_directives(node, directives)

        result = CoverageHelper.get_flattened_names(node, prefix="")

        expected_names = [
            'topdir1', 'topdir1/subdir1/file1.c', 'topdir1/subdir1', 'topdir2',
            'topdir2/subdir1', 'topdir2/subdir1/file1.c'
        ]

        self.assertEqual(result, set(expected_names))