Skip to content

Test suite runs repeated __init__ which may incorrectly mutate self.cfg paremeter #21393

@Micket

Description

@Micket

In normal use, the easyblock init methods are only called once, but when running the easybuild-easyconfigs test suite the easyblock may be constructed multiple times, and if the easyconfig cfg is mutated, it may be done so repeatedly.

This also means the problem would not occur running a single specific test.

Most easyblocks don't do much of anything, or just re-initialized the same content each time regardless, making them idempotent, but in the Cargo easyblock, we need to construct the sources list from the given list of crates.
As the sources list isn't necessarily empty from the start (you can have other sources + a list of crates), we can't very well clean out the sources either, and we end up appending the new sources to it.
And when we init multiple times, Cargo.__init__ ends up appending multiple duplicated sources.

After this change
easybuilders/easybuild-easyblocks@a9cadc4#diff-e47f470369ad66d27de6a7cb5fa577eeaf527afa731aa400c0fd20fcbb9c1c45L140
the problem reappeared here:
#21354
where the test suite fails because it's counting 2*x number of sources but only x checksums.

We either have to hack something into Cargo easyblock to make it idempotent,

if not hasattr(self.cfg, 'is_initialized'):
    self.cfg.is_initialized = True

or something like clearing out the list of crates again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions