Page MenuHomeSoftware Heritage

loader.hg: Initialize and refactor deprecated tests to use pytest fixture
ClosedPublic

Authored by ardumont on Jul 7 2020, 9:32 AM.

Details

Summary

This starts the refactoring of the loader-mercurial tests to use pytest. Taking
the same path we did for loader-svn [1] (one test at a time).

Hopefully, at some point, we will be able to reuse those tests for D3435,
maybe?

Note: This will allow to remove the unit-test based tests scaffolding from the
loader-core (once done).

Related to T2481

[1] T2462

Test Plan

tox

Diff Detail

Repository
rDLDHG Mercurial loader
Branch
migrate-pytest
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 13396
Build 20486: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 20485: arc lint + arc unit

Unit TestsFailed

TimeTest
2,068 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.mercurial.tests.test_loader::test_loader_hg_new_visit
swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_loader_hg_new_visit0/loader.yml' datadir = '/var/lib/jenkins/workspace/DLDHG/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/loader/mercurial/tests/resources' tmp_path = PosixPath('/tmp/pytest-of-jenkins/pytest-0/test_loader_hg_new_visit0')
173 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.mercurial.tests.test_loader.ArchiveLoaderTest::test_load
self = <swh.loader.mercurial.tests.test_loader.ArchiveLoaderTest testMethod=test_load> def test_load(self):
193 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.mercurial.tests.test_loader.WithReleaseLoaderTest::test_load
self = <swh.loader.mercurial.tests.test_loader.WithReleaseLoaderTest testMethod=test_load> def test_load(self):
149 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.mercurial.tests.test_loader.WithTransplantLoaderTest::test_load
self = <swh.loader.mercurial.tests.test_loader.WithTransplantLoaderTest testMethod=test_load> def test_load(self):
2 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.mercurial.tests.test_converters.TestParseAuthorConverters::test_parse_author_2
View Full Test Results (4 Failed · 14 Passed)

Event Timeline

Build has FAILED

Patch application report for D3440 (id=12176)

Rebasing onto d210f73957...

Current branch diff-target is up to date.
Changes applied before test
commit 54e14bf7e632f4a26d1603185954d3c4a9377078
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Fri Jul 3 16:00:24 2020 +0200

    Initialize and refactor deprecated tests to use pytest
    
    This will allow to remove the base tests scaffolding in core.
    
    Related to T2462

Link to build: https://jenkins.softwareheritage.org/job/DLDHG/job/tests-on-diff/16/
See console output for more information: https://jenkins.softwareheritage.org/job/DLDHG/job/tests-on-diff/16/console

build has FAILED

ah, yeah the master build is broken [1]
So that needs to be rebased on the fix.

[1] https://jenkins.softwareheritage.org/job/DLDHG/job/tests/691/console

swh/loader/mercurial/tests/test_loader.py
57

That's D3431 but trying to keep things sandboxed (as the latest swh.loader.core is not released yet)

requirements-test.txt
3

yes, should be swh.storage[testing] plus the duplication in tox.ini.

vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
requirements-test.txt
3

could you write this in a comment?

swh/loader/mercurial/tests/conftest.py
43

use pytest's tmpdir fixture

This revision is now accepted and ready to land.Jul 7 2020, 10:03 AM
requirements-test.txt
3

Well, that will go away soonishly as i plan to do as entertained as exchanged [1].
The gist of it is to expose a swh.storage.pytest_plugin.
Would that be clear enough?

[1] D3428#inline-23730

swh/loader/mercurial/tests/conftest.py
43

oh yeah ;)

  • Rebase on latest master (green build)
  • Adapt using the latest swh.loader.core testing functions

Build is green

Patch application report for D3440 (id=12195)

Rebasing onto 92e2ad85a7...

Current branch diff-target is up to date.
Changes applied before test
commit 2308eca5f55865f970dbb2b572c02c92cb3a464e
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Fri Jul 3 16:00:24 2020 +0200

    Initialize and refactor deprecated tests to use pytest
    
    This will allow to remove the base tests scaffolding in core.
    
    Related to T2462

See https://jenkins.softwareheritage.org/job/DLDHG/job/tests-on-diff/19/ for more details.

This starts the refactoring of the loader-mercurial tests to use pytest. Taking
the same path we did for loader-svn [1] (one test at a time).

I'm not sure this is the right path though (i mean 1 diff, 1 refactored test).
I see the pattern to test is quite similar to the git tests ones (using a base class
to test multiple loader implementations).

As a new one is underway, better keep this so we can simply add/replace the implementation to check when ready. maybe?

I'm not sure this is the right path though (i mean 1 diff, 1 refactored test).

Well, sure. Nonetheless, that one is unrelated to other tests so let's land it.
I'll have another look when i'm done with the main part.