Skip to content

Commit

Permalink
A test to prove that @fromfile invaldiation works now.
Browse files Browse the repository at this point in the history
See #10360
  • Loading branch information
benjyw committed Feb 1, 2025
1 parent dddc4ee commit b9514f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
7 changes: 0 additions & 7 deletions docs/docs/using-pants/key-concepts/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,6 @@ PANTS_SCOPE_OPTION=@path/to/file.json
pants --scope-option="@path/to/file.json"
```

:::caution Gotcha: If you modify the value file, you must manually restart pantsd
Until we resolve [this issue](https://github.com/pantsbuild/pants/issues/10360), changing
the value in a file used with the `@` syntax as described above will not invalidate the build.
For now, if such a file changes you will have to stop pantsd so that it will be restarted on
the next invocation of pants. To do so, run `rm -r .pants.d/pids/` in the build root.
:::

## `.pants.rc` file

You can set up personal Pants config files, using the same TOML syntax as `pants.toml`. By default, Pants looks for the paths `/etc/pantsrc`, `~/.pants.rc`, and `.pants.rc` in the repository root.
Expand Down
29 changes: 29 additions & 0 deletions src/python/pants/option/options_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,32 @@ def test_pants_symlink_workdirs(tmp_path: Path) -> None:
pants_run.assert_success()
# Make sure symlink workdir is pointing to physical workdir
assert Path(os.readlink(symlink_workdir.as_posix())) == physical_workdir


def test_fromfile_invalidation(tmp_path: Path) -> None:
workdir = (tmp_path / "workdir").as_posix()

fromfile_path = tmp_path / "fromfile.txt"
fromfile_path.write_text("dist1")
pants_run = run_pants_with_workdir(
[f"--pants-distdir=@{fromfile_path}"],
use_pantsd=True,
workdir=workdir,
)
assert "Scheduler initialized." in pants_run.stderr

pants_run = run_pants_with_workdir(
[f"--pants-distdir=@{fromfile_path}"],
use_pantsd=True,
workdir=workdir,
)
assert "Scheduler initialized." not in pants_run.stderr

fromfile_path.write_text("dist2")
pants_run = run_pants_with_workdir(
[f"--pants-distdir=@{fromfile_path}"],
use_pantsd=True,
workdir=workdir,
)
assert "Initialization options changed: reinitializing scheduler..." in pants_run.stderr
assert "Scheduler initialized." in pants_run.stderr

0 comments on commit b9514f8

Please sign in to comment.