Add a multi-package mode to `dpm test`, similar to `dpm build --all`
What is the problem you want to solve?
In a multi-package project, no single command runs the tests of all the packages in multi-package.yaml.
dpm build --all builds all the packages in multi-package.yaml. But dpm test --all has a different meaning: it runs the tests of the current package and its dependencies only. Thus, to run all the testSettle scripts in the project, I must go to each package and run dpm test --test-pattern testSettle.
IMPORTANT: the fact that
dpm test --allincludes dependency tests in a test run is very counterintuitive. This flag should have been reserved for the multi-package mode, similar todpm build --all. A different flag likedpm test --include-dependencieswould be more appropriate, but this would be a breaking change.
What is the solution you would propose?
Add a way to run the tests of all the packages in multi-package.yaml from the root of the project, for example:
dpm test --all-packages --test-pattern testSettle
The flag name is only an example. As noted previously, if you change the meaning of --all to match dpm build --all, this breaks the current behavior, so a new flag is possibly better.
The command should:
- Build each package one time.
- Run the tests of each package one time, also if other packages depend on it.
- Print one summary for the project.
Describe alternatives you've considered
- A shell loop over the packages:
dpm build --all
in_packages=false
while IFS= read -r -u 3 line; do
if [[ $line =~ ^packages:[[:space:]]*$ ]]; then
in_packages=true
elif $in_packages && [[ $line =~ ^[[:space:]]*-[[:space:]]+([^#[:space:]]+) ]]; then
pkg=${BASH_REMATCH[1]//[\"\']/}
(cd "$pkg" && dpm test --test-pattern testSettle) || exit 1
elif [[ $line =~ ^[^[:space:]#-] ]]; then
in_packages=false
fi
done 3< multi-package.yaml
This parses multi-package.yaml with a simple line match, prints one summary for each package, and does not give one coverage report.
- Run
dpm test --allin a test package that depends on all the other packages. This misses the packages that are not dependencies of that package.
Additional context
SDK version: 3.5.8 dpm version: 1.0.22
Rust's cargo has this behavior: cargo test --workspace test_settle runs the matching tests in all the workspace members, and cargo test -p <package> selects one package from the root.