diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2022-12-30 19:15:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-30 10:15:38 -0800 |
commit | b549548f6917388676fad1baf28b38e40546f6e6 (patch) | |
tree | cf7d9b7b7e1ec99d3d6f9f582959d7876e6e5390 /LICENSE-APACHE | |
parent | 79268cedd2b48cf4cebd76e46257e69afb2c1537 (diff) | |
download | spack-b549548f6917388676fad1baf28b38e40546f6e6.tar.gz spack-b549548f6917388676fad1baf28b38e40546f6e6.tar.bz2 spack-b549548f6917388676fad1baf28b38e40546f6e6.tar.xz spack-b549548f6917388676fad1baf28b38e40546f6e6.zip |
Simplify creation of test and install reports (#34712)
The code in Spack to generate install and test reports currently suffers from unneeded complexity. For
instance, we have classes in Spack core packages, like `spack.reporters.CDash`, that need an
`argparse.Namespace` to be initialized and have "hard-coded" string literals on which they branch to
change their behavior:
```python
if do_fn.__name__ == "do_test" and skip_externals:
package["result"] = "skipped"
else:
package["result"] = "success"
package["stdout"] = fetch_log(pkg, do_fn, self.dir)
package["installed_from_binary_cache"] = pkg.installed_from_binary_cache
if do_fn.__name__ == "_install_task" and installed_already:
return
```
This PR attempt to polish the major issues encountered in both `spack.report` and `spack.reporters`.
Details:
- [x] `spack.reporters` is now a package that contains both the base class `Reporter` and all
the derived classes (`JUnit` and `CDash`)
- [x] Classes derived from `spack.reporters.Reporter` don't take an `argparse.Namespace` anymore
as argument to `__init__`. The rationale is that code for commands should be built upon Spack
core classes, not vice-versa.
- [x] An `argparse.Action` has been coded to create the correct `Reporter` object based on command
line arguments
- [x] The context managers to generate reports from either `spack install` or from `spack test` have
been greatly simplified, and have been made less "dynamic" in nature. In particular, the `collect_info`
class has been deleted in favor of two more specific context managers. This allows for a simpler
structure of the code, and less knowledge required to client code (in particular on which method to patch)
- [x] The `InfoCollector` class has been turned into a simple hierarchy, so to avoid conditional statements
within methods that assume a knowledge of the context in which the method is called.
Diffstat (limited to 'LICENSE-APACHE')
0 files changed, 0 insertions, 0 deletions