Skip to content

Commit c4b5833

Browse files
connernilsenfacebook-github-bot
authored andcommitted
Add scrut tests for new config finding logic
Summary: Adds more tests for logic previously added around performing grouped upward searches and preferring `pyproject.toml` files with a `[tool.pyrefly]` section Reviewed By: grievejia Differential Revision: D83353033 fbshipit-source-id: 6a2f99fea3f76cd40bd87ed1d2ed3980b1236e58
1 parent 487a943 commit c4b5833

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

test/config.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,65 @@ Configuration at * (glob)
175175
* (glob+)
176176
[0]
177177
```
178+
179+
## We'll use the first marker file we find as a project root
180+
181+
```scrut {output_stream: stdout}
182+
$ mkdir -p $TMPDIR/config_finder/project && \
183+
> touch $TMPDIR/config_finder/pyproject.toml && \
184+
> touch $TMPDIR/config_finder/project/pyproject.toml && \
185+
> touch $TMPDIR/config_finder/project/main.py && \
186+
> $PYREFLY dump-config $TMPDIR/config_finder/project/main.py
187+
Default configuration for project root marked by `*/config_finder/project/pyproject.toml` (glob)
188+
* (glob+)
189+
[0]
190+
```
191+
192+
## We'll prefer a Pyrefly config in a parent directory to a marker file
193+
194+
<!-- Reusing configs set up in tests between here and "We'll use the first marker file we find as a project root" -->
195+
196+
```scrut {output_stream: stdout}
197+
$ touch $TMPDIR/config_finder/pyrefly.toml && \
198+
> $PYREFLY dump-config $TMPDIR/config_finder/project/main.py
199+
Configuration at `*/config_finder/pyrefly.toml` (glob)
200+
* (glob+)
201+
[0]
202+
```
203+
204+
## We'll prefer a Pyproject with Pyrefly config in a parent directory to a marker file
205+
206+
<!-- Reusing configs set up in tests between here and "We'll use the first marker file we find as a project root" -->
207+
208+
```scrut {output_stream: stdout}
209+
$ rm $TMPDIR/config_finder/pyrefly.toml && \
210+
> echo "[tool.pyrefly]" > $TMPDIR/config_finder/pyproject.toml && \
211+
> $PYREFLY dump-config $TMPDIR/config_finder/project/main.py
212+
Configuration at `*/config_finder/pyproject.toml` (glob)
213+
* (glob+)
214+
[0]
215+
```
216+
217+
## We'll use the first Pyrefly config we find
218+
219+
<!-- Reusing configs set up in tests between here and "We'll use the first marker file we find as a project root" -->
220+
221+
```scrut {output_stream: stdout}
222+
$ echo "[tool.pyrefly]" > $TMPDIR/config_finder/project/pyproject.toml && \
223+
> $PYREFLY dump-config $TMPDIR/config_finder/project/main.py
224+
Configuration at `*/config_finder/project/pyproject.toml` (glob)
225+
* (glob+)
226+
[0]
227+
```
228+
229+
## We'll prefer pyrefly.toml to pyproject.toml
230+
231+
<!-- Reusing configs set up in tests between here and "We'll use the first marker file we find as a project root" -->
232+
233+
```scrut {output_stream: stdout}
234+
$ touch $TMPDIR/config_finder/project/pyrefly.toml && \
235+
> $PYREFLY dump-config $TMPDIR/config_finder/project/main.py
236+
Configuration at `*/config_finder/project/pyrefly.toml` (glob)
237+
* (glob+)
238+
[0]
239+
```

0 commit comments

Comments
 (0)