-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows specifying which features to build, test and lint
- Loading branch information
Showing
3 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 38 additions & 2 deletions
40
kraken-build/src/kraken/std/cargo/tasks/cargo_test_task.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,48 @@ | ||
from enum import Enum, auto | ||
|
||
from kraken.core import Property | ||
|
||
from .cargo_build_task import CargoBuildTask | ||
|
||
|
||
class CargoTestIgnored(Enum): | ||
"""How to treat ignored tests""" | ||
|
||
#: Skip ignored tests | ||
SKIP = auto() | ||
|
||
#: Run ignored tests | ||
INCLUDE = auto() | ||
|
||
#: Run only ignored tests | ||
ONLY = auto() | ||
|
||
|
||
class CargoTestTask(CargoBuildTask): | ||
"""This task runs `cargo test` using the specified parameters. It will respect the authentication | ||
credentials configured in :attr:`CargoProjectSettings.auth`.""" | ||
|
||
description = "Run `cargo test`." | ||
|
||
#: When set to a list of filters, run only tests which match any of these filters. | ||
filter: Property[list[str]] = Property.default_factory(list) | ||
|
||
#: Specify how to treat ignored tests, by default they are skipped. | ||
ignored: Property[CargoTestIgnored] = Property.default(CargoTestIgnored.SKIP) | ||
|
||
def get_cargo_command(self, env: dict[str, str]) -> list[str]: | ||
super().get_cargo_command(env) | ||
return ["cargo", "test"] + self.additional_args.get() | ||
command = super().get_cargo_subcommand(env, "test") | ||
command.append("--") | ||
|
||
match self.ignored.get(): | ||
case CargoTestIgnored.SKIP: | ||
pass | ||
case CargoTestIgnored.INCLUDE: | ||
command.append("--include-ignored") | ||
case CargoTestIgnored.ONLY: | ||
command.append("--ignored") | ||
|
||
for filter in self.filter.get(): | ||
command.append(filter) | ||
|
||
return command |