-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: relax directory target rules
allow non sandboxed rules to produce directory targets Signed-off-by: Rudi Grinberg <me@rgrinberg.com> ps-id: 49c39ffb-67c2-4ea1-9b33-ea5be360f5bb
- Loading branch information
Showing
7 changed files
with
118 additions
and
48 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
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
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
88 changes: 88 additions & 0 deletions
88
test/blackbox-tests/test-cases/directory-targets/no-sandboxing.t
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
Tests for directory targets that are produced by unsandboxed rule | ||
|
||
$ cat > dune-project <<EOF | ||
> (lang dune 3.4) | ||
> (using directory-targets 0.1) | ||
> EOF | ||
|
||
Build directory target from the command line without sandboxing | ||
|
||
$ cat > dune <<EOF | ||
> (rule | ||
> (targets (dir output)) | ||
> (action (system "mkdir output; echo x > output/x; echo y > output/y"))) | ||
> EOF | ||
|
||
$ dune build output/x | ||
$ cat _build/default/output/x | ||
x | ||
$ cat _build/default/output/y | ||
y | ||
|
||
We ask to build a file that doesn't exist inside the directory: | ||
|
||
$ dune build output/fake | ||
File "dune", line 1, characters 0-102: | ||
1 | (rule | ||
2 | (targets (dir output)) | ||
3 | (action (system "mkdir output; echo x > output/x; echo y > output/y"))) | ||
Error: This rule defines a directory target "output" that matches the | ||
requested path "output/fake" but the rule's action didn't produce it | ||
[1] | ||
|
||
When we fail to create the directory, dune complains: | ||
|
||
$ cat > dune <<EOF | ||
> (rule | ||
> (targets (dir output)) | ||
> (action (system "true"))) | ||
> EOF | ||
|
||
$ dune build output/ | ||
File "dune", line 1, characters 0-56: | ||
1 | (rule | ||
2 | (targets (dir output)) | ||
3 | (action (system "true"))) | ||
Error: Rule failed to produce directory "output" | ||
[1] | ||
|
||
Check that Dune clears stale files from directory targets. | ||
|
||
$ cat >dune <<EOF | ||
> (rule | ||
> (deps src_a src_b src_c) | ||
> (targets (dir output)) | ||
> (action (bash "\| echo running; | ||
> "\| mkdir -p output/subdir; | ||
> "\| cat src_a > output/new-a; | ||
> "\| cat src_b > output/subdir/b | ||
> ))) | ||
> (rule | ||
> (deps output) | ||
> (target contents) | ||
> (action (bash "echo running; echo 'new-a:' > contents; cat output/new-a >> contents; echo 'b:' >> contents; cat output/subdir/b >> contents"))) | ||
> EOF | ||
|
||
$ echo a > src_a | ||
$ echo b > src_b | ||
$ echo c > src_c | ||
$ dune build contents | ||
running | ||
running | ||
Directory target whose name conflicts with an internal directory used by Dune. | ||
|
||
$ cat > dune <<EOF | ||
> (rule | ||
> (targets (dir .dune)) | ||
> (action (bash "mkdir .dune; echo hello > .dune/hello"))) | ||
> EOF | ||
|
||
$ dune build .dune/hello | ||
File "dune", line 1, characters 0-88: | ||
1 | (rule | ||
2 | (targets (dir .dune)) | ||
3 | (action (bash "mkdir .dune; echo hello > .dune/hello"))) | ||
Error: This rule defines a target ".dune" whose name conflicts with an | ||
internal directory used by Dune. Please use a different name. | ||
[1] | ||
|