RepoSplit/tests: flag/update more unit tests away from relying on the builtin repository#48930
RepoSplit/tests: flag/update more unit tests away from relying on the builtin repository#48930tldahlgren wants to merge 56 commits intospack:developfrom
Conversation
7f078d0 to
293e4dc
Compare
293e4dc to
8f2fa0c
Compare
33f161a to
bd1b26e
Compare
c8e65ea to
6031143
Compare
6031143 to
a72eb64
Compare
11e947c to
b14d2b2
Compare
54e4a19 to
ace6037
Compare
alalazo
left a comment
There was a problem hiding this comment.
I started reviewing this PR, and left a few comments. In general, I think there are many parts that can be extracted into their own small PR, and merged.
| @pytest.fixture | ||
| def mock_gcc(mutable_config): | ||
| # Data for a compiler if there are none available | ||
| _gcc_compiler_definition = { | ||
| "compiler": { | ||
| "spec": "[email protected]", | ||
| "paths": { | ||
| "cc": "/usr/bin/gcc-9", | ||
| "cxx": "/usr/bin/g++-9", | ||
| "f77": "/usr/bin/gfortran-9", | ||
| "fc": "/usr/bin/gfortran-9", | ||
| }, | ||
| "flags": {}, | ||
| "operating_system": "ubuntu18.04", | ||
| "target": "x86_64", | ||
| "modules": [], | ||
| "environment": {}, | ||
| "extra_rpaths": [], | ||
| } | ||
| } | ||
|
|
||
| compilers_before = spack.config.get("compilers", []) | ||
| supported_compilers = spack.compilers.config.supported_compilers() | ||
|
|
||
| # Ensure have at least one gcc compiler | ||
| with spack.config.override("compilers", [_gcc_compiler_definition]): | ||
| compilers = spack.compilers.config.all_compilers() | ||
| assert compilers, "No compilers available" | ||
|
|
||
| compilers.sort(key=lambda x: (x.name == "gcc", x.version)) | ||
| # Deepcopy is used to avoid more boilerplate when changing the "extra_attributes" | ||
| return copy.deepcopy(compilers[-1]) |
There was a problem hiding this comment.
Why did we change the mock here to use the deprecated compiler: configuration?
There was a problem hiding this comment.
I started that from something else and neglected to update it. Thanks for pointing it out!
| @pytest.mark.not_on_windows("Not supported on Windows") | ||
| def test_compile_dummy_c_source(self, mock_gcc, monkeypatch, language, flagname): | ||
| def test_compile_dummy_c_source( | ||
| self, mock_packages, mock_gcc, monkeypatch, language, flagname |
There was a problem hiding this comment.
Instead of adding mock_packages everywhere, did we consider adding it only once at the class level:
@pytest.mark.usefixtures("mock_packages")
class TestCompilerPropertyDetector:?
There was a problem hiding this comment.
IIRC Unmarked unit tests failed. I'll revisit.
| return self._external_spec(result) | ||
|
|
||
| def _external_spec(self, initial_spec) -> "spack.spec.Spec": | ||
| # TODO/RepoSplit: Convert to namespace of new or bootstrap pkg repo |
There was a problem hiding this comment.
Why would we need to convert? I assume we won't change the "builtin" namespace? Or maybe I'm reading the comment wrong?
There was a problem hiding this comment.
I added the comment as a placeholder for a quick search that pre-dates Harmen's work.
| For instance: | ||
|
|
||
| python_package_for_repo('builtin') == 'spack.pkg.builtin' | ||
| python_package_for_repo('builtin.mock') == 'spack.pkg.builtin.mock' |
There was a problem hiding this comment.
We don't really need to change the example in the docstring, do we?
There was a problem hiding this comment.
Fair enough. Things were still "up in the air" at the time I made the change. Plus I wasn't sure how we wanted or were going to reference what we currently refer to as builtin.
|
|
||
| @pytest.fixture() | ||
| def mock_compiler(mock_executable): | ||
| def mock_gcc_yaml(mock_executable): |
There was a problem hiding this comment.
Let's continue to call it mock_compiler, or if we want to be more specific mock_legacy_compiler or legacy_compiler_yaml. The compiler part refers to the deprecated compiler: section of the configuration that these tests are about.
There was a problem hiding this comment.
Switching/switched to legacy_compiler_yaml since the change was motivated by my I adding a different mock_compilers to conftest.py.
| from spack.package import * | ||
|
|
||
|
|
||
| class CrayMpich(Package): |
There was a problem hiding this comment.
Why was it necessary to add this package? Not clear from the description? Is there some test that strictly depend on it?
There was a problem hiding this comment.
Yes, the three starting test/package_class.py::test_possible_dependencies.
There was a problem hiding this comment.
Going over the commits, it was initially needed for test/cray_manifest.py tests.
There was a problem hiding this comment.
This does not appear to be needed anymore within the contexts of running the test modules test/cmd/dependencies.py, test/cray_manifest.py, and test_package_class.py independently when the builtin repository isn't available.
Note: The exception to this finding and others previously flagged is that, in general, there are still dependencies on compiler-wrappers and or gcc-runtime being symbolically linked to their builtin repository packages.
|
@alalazo Thank you for the detailed feedback! |
|
Closing since nearly all independent changes have been moved to other pull requests. |
This PR flags code that will need to be revisited when the package repository is actually split off from the core. All but about four to six unit tests relying on the
builtinrepository have been converted to usebuiltin.mock. This was accomplished initially by renamingbuiltinso it would not be found whenspack unit-testwas run and, later, changingtest/data/config/repos.yamlto use the mock repository to pick up more unit tests.In my testing on linux, it appeared that only four of the five
test_load_json_specfileschecks won't work if thebuiltinrepository is "removed". These tests rely on checks relying on version-specific JSON files based on thebuiltinHDF5package. A mock version of that package wasn't added untilv0.16. Instead of continuing to address these last four failing tests, this PR added aTODOnote indicating the need to address the tests in a subsequent PR.TODO
test/compilers/libraries.pysucceeds on its own but tests fail for lack ofgccwhen run all(?) unit tests (i.e., What are the sources of test setup overlap?).testrepos tobuiltinfor selected packages