Skip to content

RepoSplit/tests: flag/update more unit tests away from relying on the builtin repository#48930

Closed
tldahlgren wants to merge 56 commits intospack:developfrom
tldahlgren:reposplit_more_tests
Closed

RepoSplit/tests: flag/update more unit tests away from relying on the builtin repository#48930
tldahlgren wants to merge 56 commits intospack:developfrom
tldahlgren:reposplit_more_tests

Conversation

@tldahlgren
Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren commented Feb 7, 2025

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 builtin repository have been converted to use builtin.mock. This was accomplished initially by renaming builtin so it would not be found when spack unit-test was run and, later, changing test/data/config/repos.yaml to 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_specfiles checks won't work if the builtin repository is "removed". These tests rely on checks relying on version-specific JSON files based on the builtin HDF5 package. A mock version of that package wasn't added until v0.16. Instead of continuing to address these last four failing tests, this PR added a TODO note indicating the need to address the tests in a subsequent PR.

TODO

  • Determine why test/compilers/libraries.py succeeds on its own but tests fail for lack of gcc when run all(?) unit tests (i.e., What are the sources of test setup overlap?)
  • Investigate/resolve other new post-compilers-as-nodes test failures
  • Determine if there is a better solution to repository package symlinks from mock and .test repos to builtin for selected packages

@spackbot-app spackbot-app bot added core PR affects Spack core functionality new-version tests General test capability(ies) labels Feb 7, 2025
@tldahlgren tldahlgren changed the title [WIP] Reposplit: flag/update more unit tests [WIP] RepoSplit/tests: flag/update more unit tests away from relying on the builtin repository Feb 7, 2025
@tldahlgren tldahlgren force-pushed the reposplit_more_tests branch from 7f078d0 to 293e4dc Compare March 7, 2025 01:59
@spackbot-app spackbot-app bot added the commands label Mar 7, 2025
@tldahlgren tldahlgren force-pushed the reposplit_more_tests branch from 293e4dc to 8f2fa0c Compare March 7, 2025 17:15
@tldahlgren tldahlgren marked this pull request as ready for review March 7, 2025 18:33
@tldahlgren tldahlgren force-pushed the reposplit_more_tests branch 3 times, most recently from 33f161a to bd1b26e Compare March 25, 2025 01:41
@tldahlgren tldahlgren changed the title [WIP] RepoSplit/tests: flag/update more unit tests away from relying on the builtin repository RepoSplit/tests: flag/update more unit tests away from relying on the builtin repository Mar 25, 2025
@tldahlgren tldahlgren requested review from alalazo and haampie March 25, 2025 23:35
@tldahlgren tldahlgren force-pushed the reposplit_more_tests branch from c8e65ea to 6031143 Compare April 1, 2025 00:47
@tldahlgren tldahlgren added this to the v1.0.0 milestone Apr 2, 2025
@tldahlgren tldahlgren force-pushed the reposplit_more_tests branch from 6031143 to a72eb64 Compare April 4, 2025 22:17
@tldahlgren tldahlgren marked this pull request as draft April 11, 2025 00:37
@tldahlgren tldahlgren force-pushed the reposplit_more_tests branch from 11e947c to b14d2b2 Compare April 11, 2025 01:02
@tldahlgren tldahlgren force-pushed the reposplit_more_tests branch from 54e4a19 to ace6037 Compare April 28, 2025 16:42
@spackbot-app spackbot-app bot added the stand-alone-tests Stand-alone (or smoke) tests for installed packages label Apr 28, 2025
@tldahlgren tldahlgren marked this pull request as ready for review May 3, 2025 01:05
Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +29 to +60
@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])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did we change the mock here to use the deprecated compiler: configuration?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of adding mock_packages everywhere, did we consider adding it only once at the class level:

@pytest.mark.usefixtures("mock_packages")
class TestCompilerPropertyDetector:

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why would we need to convert? I assume we won't change the "builtin" namespace? Or maybe I'm reading the comment wrong?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't really need to change the example in the docstring, do we?

Copy link
Copy Markdown
Contributor Author

@tldahlgren tldahlgren May 5, 2025

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And another...


@pytest.fixture()
def mock_compiler(mock_executable):
def mock_gcc_yaml(mock_executable):
Copy link
Copy Markdown
Member

@alalazo alalazo May 3, 2025

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why was it necessary to add this package? Not clear from the description? Is there some test that strictly depend on it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, the three starting test/package_class.py::test_possible_dependencies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Going over the commits, it was initially needed for test/cray_manifest.py tests.

Copy link
Copy Markdown
Contributor Author

@tldahlgren tldahlgren May 7, 2025

Choose a reason for hiding this comment

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

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.

@tldahlgren
Copy link
Copy Markdown
Contributor Author

@alalazo Thank you for the detailed feedback!

This was referenced May 5, 2025
@tldahlgren
Copy link
Copy Markdown
Contributor Author

Closing since nearly all independent changes have been moved to other pull requests.

@tldahlgren tldahlgren closed this May 14, 2025
@tldahlgren tldahlgren deleted the reposplit_more_tests branch June 2, 2025 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality dependencies new-variant new-version stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) virtual-dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants