Skip to content

Commit

Permalink
[internal] Track side-effects in RuleRunner.run_goal_rule to preven…
Browse files Browse the repository at this point in the history
…t spurious restarts. (#13385)

Unlike `run_rule_with_mocks`, `RuleRunner.run_goal_rule` does actually run a `Goal` via the engine, and is thus subject to being restarted when its inputs have changed (see #13178). Consequently, the `Console` and `Workspace` types _do_ need to track side-effects in that context, in order to prevent the `@rule` from being restarted after its first side-effect.

This was exhibiting as test flakiness for a goal that re-writes files in the workspace (see #13383), because after writing the updated lockfile to disk, the `@rule` has changed its own inputs and is subject to restart: if the restart arrived before any `Console` output was written, the second attempt to run the rule would not find anything to do, and would thus not render any `Console` output.

Fixes #13383.

[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
stuhood authored Oct 28, 2021
1 parent 35d231d commit c879c40
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python/pants/testutil/rule_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ def run_goal_rule(
specs = SpecsParser(self.build_root).parse_specs(raw_specs)

stdout, stderr = StringIO(), StringIO()
console = Console(stdout=stdout, stderr=stderr, use_colors=False)
console = Console(stdout=stdout, stderr=stderr, use_colors=False, session=self.scheduler)

exit_code = self.scheduler.run_goal_rule(
goal,
Params(
specs,
console,
Workspace(self.scheduler, _enforce_effects=False),
Workspace(self.scheduler),
),
)

Expand Down

0 comments on commit c879c40

Please sign in to comment.