Skip to content

Conversation

@sergisiso
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.96%. Comparing base (97dd02d) to head (66129b0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3258      +/-   ##
==========================================
+ Coverage   99.91%   99.96%   +0.04%     
==========================================
  Files         376      376              
  Lines       53529    53482      -47     
==========================================
- Hits        53484    53461      -23     
+ Misses         45       21      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sergisiso
Copy link
Collaborator Author

@arporter This is ready for review. It brings the codecov misses from 45 to 27 and adds no-cover pragmas to the remaining (maybe you know how to do better in the remaining?). I also added a more strict reporting for deleted lines (indirect changes).

@arporter arporter changed the title (closes #3250) Complete code coverage (closes #3250 #279) Complete code coverage Dec 17, 2025
Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for tackling this Sergi.
There are a couple of cases where I think we can add tests rather than no-cover pragmas. Also, you've removed some validation code from ACCEnterDataTrans and I don't understand why.

# mixed-precision kernel.
alg_precision = api_config.precision_map[alg_arg.precision]
if alg_precision != actual_precision:
if alg_precision != actual_precision: # pragma: no-cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding the following test to lfric_kern_test.py will cover this line. I'll let you write a suitable docstring :-)

def test_validate_kernel_code_arg_against_alg_arg(monkeypatch):
    '''
    '''
    psy, invoke = get_invoke("26.8_mixed_precision_args.f90", TEST_API,
                             name="invoke_0", dist_mem=False)
    sched = invoke.schedule
    # Second kernel has args of precision r_solver.
    kernel = sched.walk(LFRicKern, stop_type=LFRicKern)[1]
    read_access = ArgumentInterface(ArgumentInterface.Access.READ)
    lfric_real_scalar_symbol = LFRicTypes("LFRicRealScalarDataSymbol")(
        "scalar", interface=read_access)
    with pytest.raises(GenerationError) as err:
        kernel._validate_kernel_code_arg(lfric_real_scalar_symbol,
                                         lfric_real_scalar_symbol,
                                         kernel.args[0])
    assert ("Precision (4 bytes) of algorithm-layer argument "
            "'scalar_r_solver' does not match that (8 bytes) of the "
            "corresponding kernel subroutine argument 'scalar' for kernel "
            "'mixed_code'" in str(err.value))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# if the kernel requires a grid-property argument.
return None

@property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you've also update lfric.py (thanks) so I've added #279 to the issues this PR will close (as I've grepped and those are the only mentions).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

return [self._field]

def check_vector_halos_differ(self, node):
def check_vector_halos_differ(self, node): # pragma: no-cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

psyGen_test does have some tests of this method so it can't all be uncovered? In fact, I've grepped and it seems this method is completely unused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I delete it and there was no issues

# no cover: start
try:
# pylint disable=import-outside-toplevel
from termcolor import colored
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we monkeypatch the packages that appear to be available from termcolor? I had a google and found https://stackoverflow.com/questions/8658043/how-to-mock-an-import

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think it's quite important to get coverage for this because if we somehow broke it it would break a lot of stuff!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted this for now, as I see we have the same problem with graphviz and I have not yet figure out how to solve it



def test_invalid_field_accesses_for_iteration_space():
''' Tests that we when retrieving the iteration_space_arg we validate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/we when/when/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

''' UnsupportedType is abstract so sub-class it for this test '''
def __str__(self):
return "OtherType"
...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know you could do that!



def test_empty_program_handler(parser):
'''Test that an empty program handler still returns a FileContainer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the program handler still returns a FileContainer for an empty program" perhaps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's better

# extract async. Default to False.
async_queue = options.get('async_queue', False)

# check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come you've removed this? I see we still support the specification of an async_queue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we checked that all directives in the same schedule had the same async_queue? Wouldn't that mean that we cannot do ACCEnterData asynchronously at all?

try:
kernels = node.get_callees()
except SymbolError as err:
except SymbolError as err: # pragma: no-cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be easy to cover as we can monkeypatch node.get_callees() with a function that just raises SymbolError.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sergisiso
Copy link
Collaborator Author

@arporter This is ready for another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants