# Path: dev_tools/incremental_coverage.py
# IGNORED_FILE_PATTERNS = [
#     r'^dev_tools/.+',  # Environment-heavy code.
#     r'^.+_pb2(_grpc)?\.py$',  # Auto-generated protobuf code.
#     r'^setup\.py$',  # Installation code.
#     r'^docs/.+$',  # Documentation
# ]
# IGNORED_LINE_PATTERNS = [
#     # Imports often uncovered due to version checks and type checking blocks.
#     r'^import .+$',
#     r'^from .+ import .+$',
#     # Else lines are redundant w.r.t. other lines.
#     r'^else:$',
#     # Lines that are only invoked when running the file as the main file.
#     r'^main\(.+$',
#     r'^app.run\(main\)$',
#     # Empty method definitions.
#     r'^pass$',
#     # Code explicitly marked as not implemented.
#     r'raise NotImplementedError\(.+',
# ]
# EXPLICIT_OPT_OUT_COMMENT = '#coverage:ignore'
# def diff_to_new_interesting_lines(unified_diff_lines: List[str]
#                                   ) -> Dict[int, str]:
# def fix_line_from_coverage_file(line):
# def get_incremental_uncovered_lines(abs_path: str,
#                                     base_commit: str,
#                                     actual_commit: Optional[str]
#                                     ) -> List[Tuple[int, str, str]]:
# def line_content_counts_as_uncovered_manual(content: str) -> bool:
# def determine_ignored_lines(content: str) -> Set[int]:
# def naive_find_end_of_scope(lines: List[str], i: int) -> int:
# def line_counts_as_uncovered(line: str,
#                              is_from_cover_annotation_file: bool) -> bool:
# def is_applicable_python_file(rel_path: str) -> bool:
# def check_for_uncovered_lines(env: env_tools.PreparedEnv) -> int:


from dev_tools import incremental_coverage
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



def test_determine_ignored_lines():
    f = incremental_coverage.determine_ignored_lines

    assert f("a = 0  # coverage: ignore") == {1}

    assert f("""
        a = 0  # coverage: ignore
        b = 0
    """) == {2}

    assert f("""
        a = 0  
        b = 0  # coverage: ignore
    """) == {3}

    assert f("""

# Path: dev_tools/incremental_coverage.py
# IGNORED_FILE_PATTERNS = [
#     r'^dev_tools/.+',  # Environment-heavy code.
#     r'^.+_pb2(_grpc)?\.py$',  # Auto-generated protobuf code.
#     r'^setup\.py$',  # Installation code.
#     r'^docs/.+$',  # Documentation
# ]
# IGNORED_LINE_PATTERNS = [
#     # Imports often uncovered due to version checks and type checking blocks.
#     r'^import .+$',
#     r'^from .+ import .+$',
#     # Else lines are redundant w.r.t. other lines.
#     r'^else:$',
#     # Lines that are only invoked when running the file as the main file.
#     r'^main\(.+$',
#     r'^app.run\(main\)$',
#     # Empty method definitions.
#     r'^pass$',
#     # Code explicitly marked as not implemented.
#     r'raise NotImplementedError\(.+',
# ]
# EXPLICIT_OPT_OUT_COMMENT = '#coverage:ignore'
# def diff_to_new_interesting_lines(unified_diff_lines: List[str]
#                                   ) -> Dict[int, str]:
# def fix_line_from_coverage_file(line):
# def get_incremental_uncovered_lines(abs_path: str,
#                                     base_commit: str,
#                                     actual_commit: Optional[str]
#                                     ) -> List[Tuple[int, str, str]]:
# def line_content_counts_as_uncovered_manual(content: str) -> bool:
# def determine_ignored_lines(content: str) -> Set[int]:
# def naive_find_end_of_scope(lines: List[str], i: int) -> int:
# def line_counts_as_uncovered(line: str,
#                              is_from_cover_annotation_file: bool) -> bool:
# def is_applicable_python_file(rel_path: str) -> bool:
# def check_for_uncovered_lines(env: env_tools.PreparedEnv) -> int:


# Path: dev_tools/incremental_coverage_test.py
from dev_tools import incremental_coverage

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



def test_determine_ignored_lines():
    f = incremental_coverage.determine_ignored_lines

    assert f("a = 0  # coverage: ignore") == {1}

    assert f("""
        a = 0  # coverage: ignore
        b = 0
    """) == {2}

    assert f("""
        a = 0  
        b = 0  # coverage: ignore
    """) == {3}

    assert f("""

        a = 0  # coverage: ignore  