Conversation
…ntioned by the user with the 'spack install' command
|
Nice! I also like the '--test-root' option. |
|
Someone brought up the point that something similar to this could be achieved by adding a "test" variant to packages with additional dependencies and automatically enabling this variant when The PR is implemented as it is now because some packages don't change at all when testing is added, even if additional dependencies are required for testing (a variant changes the dag hash so building a package with and without testing would count as different package instances). For packages that change when testing is performed (e.g. the binaries differ) they should include a |
This is pretty frustrating (the second half of the sentence). Whenever I make modifications to Python packages, I try installing all of them to see if they work. I've noticed that I'll end up with 4 or 5 copies of the same package, same version, same variants, same compilers, but different hash. I believe the reason is that certain packages influence the dependency type of other dependencies (for example, a package that has a |
i think this is the most common case. Otherwise, indeed, it should be a variant which probably does something extra than just running tests. |
#4595 ought to help with that (+ maybe a bit of extra work depending on the particulars of your case). |
|
I did some testing with PR#4907 and it seems to work. (though I may have uncovered a buglet in Spack's ctest interface). One thing to consider, perhaps not relevant for initial version of test deptype, is that there are scenarios where you will want to test a package after it has already been built and installed. This would be relevant for a cross-compile architectures like BlueGene/Q. You compile on the front-end/login node. Then you have to submit a batch job to run the test on back-end/compute nodes. |
lib/spack/spack/cmd/install.py
Outdated
| ) | ||
| subparser.add_argument( | ||
| '--run-tests', action='store_true', dest='run_tests', | ||
| '--test-all', action='store_true', dest='test_all', |
There was a problem hiding this comment.
What do you think about having a single argument --test that could take values all and root? This will make the 2 options mutually exclusive, and allow for seamless extensions in the future without adding additional arguments.
There was a problem hiding this comment.
I agree - I'll try to add this today
… option that can be either 'root' or 'all' (or unset)
|
Reopening to rerun tests |
@adamjstewart: too slowly but it's happening. I'm hoping it fixes all the pain! |
@naromero77: I have kicked around some ideas for this with Barry Smith and I really would really like to support this with a simple command API (e.g., So there are things to work out. I think it's doable but there's a larger topic around how best to work all the HPC details in. Everything's easier on plain old intel linux :(. |
tgamblin
left a comment
There was a problem hiding this comment.
@scheibelp: some really minor change requests and some comments.
This PR is pretty awesome -- it adds good enough test dependencies and it only adds 3 lines to spec.py. Nice.
I would like to eventually put in better testing capabilities like @naromero77 wants but I think this is pretty good for now, and it greatly enhances what is already there.
Do you want to merge this first, or should we merge #5476 first? I think they will conflict slightly, but rebasing this may be easier. Thoughts?
| help="spec of the package to install" | ||
| ) | ||
| subparser.add_argument( | ||
| '--run-tests', action='store_true', |
There was a problem hiding this comment.
I think we should probably keep this argument here for a little while -- I suspect people use it in their CI scripts. Can you leave it in like this?
subparser.add_argument(
'--run-tests', action='store_const', dest='test', const='all',
help='run package tests during installation (same as --test=all)'I think that will interact correctly with the new --test= (though they should probably be mutually exclusive).
There was a problem hiding this comment.
Just throwing in an idea. If we want to be backward compatible, we could write a custom action that handles both --test= and --run-tests. The action should tty.warn users if they are employing --run-tests and suggest an update to the --test=all equivalent. We could leave the warning there for a while and then be "justified" for a later removal of the option.
lib/spack/spack/test/cmd/install.py
Outdated
| @pytest.mark.usefixtures('mock_calls_for_install', 'builtin_mock', 'config') | ||
| def test_install_runtests(): | ||
| install('--test=root', 'dttop') | ||
| assert spack.package_prefs.PackageTesting.test.call_count == 1 |
There was a problem hiding this comment.
Seems like you could check not just the call count but whether the only thing in there is dttop. PackageTesting has the information since test() is passed the package name, right? Checking for 1 call is necessary but not sufficient.
lib/spack/spack/test/cmd/install.py
Outdated
| assert spack.package_prefs.PackageTesting.test.call_count == 1 | ||
|
|
||
| install('--test=all', 'a') | ||
| assert spack.package_prefs.PackageTesting.test_all.call_count == 1 |
lib/spack/spack/test/spec_dag.py
Outdated
| return _mock | ||
|
|
||
|
|
||
| class MockPackage(object): |
There was a problem hiding this comment.
I can't decide whether I like these or not. They're obviously useful and the implementation here is pretty simple and clean. But we also have builtin_mock -- should these be new packages there? These have the advantage that the info you need to understand a test is entirely contained within the test, while builtin.mock is becoming pretty sprawling. OTOH, builtin.mock actually tests package parsing and the Spack DSL. So I dunno.
Probably it is ok to have both, at least for now. So maybe MockPackage and friends should go in conftest.py so they're usable everywhere?
There was a problem hiding this comment.
These have the advantage that the info you need to understand a test is entirely contained within the test, while builtin.mock
That's the main reason I did this and I think it's a really good one. I also use exactly the same new definitions when testing DAGs in #4595 and I think it will be useful for exercising any complex DAG structure.
OTOH, builtin.mock actually tests package parsing and the Spack DSL. So I dunno.
I think that while this advocates for not eliminating builtin.mock, it does not mean this is redundant. Testing package parsing and Spack's DSL is important but doesn't have to be done in every test. In fact, arguably unit tests should be as targeted as possible and IMO more tests would benefit from using the MockPackage objects defined here instead of builtin.mock.
|
Thanks for the review! I'll work on addressing the comments by the end of 9/29. |
|
Many thanks |
@tgamblin I think either can go in first. I have a slight preference for this going in first since I think it touches less of the core. I wouldn't hold up one for the other though. |
…l, and make it mutually exclusive with the --test option
|
@scheibelp: ok sounds good -- let's merge this first. I think the changes here are pretty small, so if @naromero77 wants to test with this and dependency patching as they are now, I think we should merge this, dep patching, and qmcpack once you update this one. |
…dd check for --run-tests
|
@tgamblin I have made edits to address review comments. Let me know if more is needed. |
|
@scheibelp: thanks! |
|
@naromero77: this is merged. |
|
@tgamblin thanks |
Fixes #1279
Specify that certain dependencies are for testing only. These packages are treated like build dependencies:
This also replaces the
--run-testsoption forspack installwith two options--test-all: same behavior as previous--run-testsoption; tests all packages in the DAG--test-root: test only the top-level package in the dag. I found this useful for the case oflibpslwhich wanted to run tests for the python dependency in the--test-allcase.I've only tested this so far with
libpsl