-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ali Caglayan <alizter@gmail.com> <!-- ps-id: 28962076-9451-4253-be23-14d44a88eec0 --> Signed-off-by: Ali Caglayan <alizter@gmail.com>
- Loading branch information
Showing
21 changed files
with
252 additions
and
15 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
I am file A. |
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 @@ | ||
I am file B. |
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 @@ | ||
I am file C. |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/actions/conc-multi-diff.t/dune-project
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 @@ | ||
(lang dune 3.7) |
84 changes: 84 additions & 0 deletions
84
test/blackbox-tests/test-cases/actions/conc-multi-diff.t/run.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,84 @@ | ||
Illustration of the use of (conc ) in the context of diffing multiple files. | ||
|
||
Say we want to diff 3 files. | ||
$ cat A | ||
I am file A. | ||
$ cat B | ||
I am file B. | ||
$ cat C | ||
I am file C. | ||
|
||
We set up a (progn ) rule to diff all of them against their generated versions. | ||
|
||
$ cat > dune << EOF | ||
> (rule | ||
> (action | ||
> (progn | ||
> (with-outputs-to A.diff (echo "I am file A.\n")) | ||
> (with-outputs-to B.diff (echo "I am certainly file B.\n")) | ||
> (with-outputs-to C.diff (echo "I am most certainly file C.\n"))))) | ||
> | ||
> (rule | ||
> (action | ||
> (progn | ||
> (with-outputs-to some-target (echo a)) | ||
> (diff %{dep:A} %{dep:A.diff}) | ||
> (diff %{dep:B} %{dep:B.diff}) | ||
> (diff %{dep:C} %{dep:C.diff})))) | ||
> EOF | ||
|
||
We can now run the rule and see that we fail before diffing C. | ||
|
||
$ dune build | ||
File "B", line 1, characters 0-0: | ||
Error: Files _build/default/B and _build/default/B.diff differ. | ||
[1] | ||
|
||
We can check which diffs were run by asking Dune to promote the files. | ||
|
||
$ dune promotion apply | ||
Promoting _build/default/B.diff to B. | ||
|
||
Since we failed early, only B was promoted. | ||
|
||
Let's reset B to its original state. | ||
|
||
$ rm B | ||
$ cat > B << EOF | ||
> I am file B. | ||
> EOF | ||
|
||
If we implement the rule using (conc ) instead. | ||
|
||
$ cat > dune << EOF | ||
> (rule | ||
> (action | ||
> (progn | ||
> (with-outputs-to A.diff (echo "I am file A.\n")) | ||
> (with-outputs-to B.diff (echo "I am certainly file B.\n")) | ||
> (with-outputs-to C.diff (echo "I am most certainly file C.\n"))))) | ||
> | ||
> (rule | ||
> (action | ||
> (conc | ||
> (with-outputs-to some-target (echo a)) | ||
> (diff %{dep:A} %{dep:A.diff}) | ||
> (diff %{dep:B} %{dep:B.diff}) | ||
> (diff %{dep:C} %{dep:C.diff})))) | ||
> EOF | ||
|
||
We see that all the files get diffed. | ||
|
||
$ dune build | ||
File "B", line 1, characters 0-0: | ||
Error: Files _build/default/B and _build/default/B.diff differ. | ||
File "C", line 1, characters 0-0: | ||
Error: Files _build/default/C and _build/default/C.diff differ. | ||
[1] | ||
|
||
And we have promotions for the two that failed. | ||
|
||
$ dune promote | ||
Promoting _build/default/B.diff to B. | ||
Promoting _build/default/C.diff to C. | ||
|
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,107 @@ | ||
Specification of the concurrency action: | ||
|
||
$ cat > dune-project << EOF | ||
> (lang dune 3.6) | ||
> EOF | ||
|
||
$ cat > dune << EOF | ||
> (rule | ||
> (action | ||
> (conc ))) | ||
> EOF | ||
|
||
$ dune build | ||
File "dune", line 3, characters 2-9: | ||
3 | (conc ))) | ||
^^^^^^^ | ||
Error: 'conc' is only available since version 3.7 of the dune language. | ||
Please update your dune-project file to have (lang dune 3.7). | ||
[1] | ||
|
||
Requires Dune 3.7. | ||
|
||
$ cat > dune-project << EOF | ||
> (lang dune 3.7) | ||
> EOF | ||
|
||
It works just like progn. | ||
|
||
$ dune build | ||
File "dune", line 1, characters 0-26: | ||
1 | (rule | ||
2 | (action | ||
3 | (conc ))) | ||
Error: Rule has no targets specified | ||
[1] | ||
|
||
$ cat > dune << EOF | ||
> (rule | ||
> (action | ||
> (conc | ||
> (progn (system "") (echo "A\n")) | ||
> (progn (echo "B\n")) | ||
> (with-outputs-to some-target (progn) )))) | ||
> EOF | ||
|
||
But runs the actions concurrently. Seen here by adding some delay to the | ||
printing of A. | ||
|
||
$ dune build | ||
B | ||
A | ||
|
||
Another key difference is that errors do not stop the whole action. | ||
|
||
Here is the situation for (progn ): | ||
|
||
$ cat > dune << EOF | ||
> (rule | ||
> (action | ||
> (progn | ||
> (progn (echo "A!\n")) | ||
> (progn (system "exit 1") (echo B)) | ||
> (progn (echo "C\n")) | ||
> (with-outputs-to some-target (echo some-target))))) | ||
> EOF | ||
|
||
$ dune build | ||
A! | ||
File "dune", line 1, characters 0-165: | ||
1 | (rule | ||
2 | (action | ||
3 | (progn | ||
4 | (progn (echo "A!\n")) | ||
5 | (progn (system "exit 1") (echo B)) | ||
6 | (progn (echo "C\n")) | ||
7 | (with-outputs-to some-target (echo some-target))))) | ||
Command exited with code 1. | ||
[1] | ||
|
||
And here is the situation for (conc ): | ||
|
||
$ cat > dune << EOF | ||
> (rule | ||
> (action | ||
> (conc | ||
> (progn (echo "A\n")) | ||
> (progn (system "exit 1") (echo B)) | ||
> (progn (echo "C\n")) | ||
> (with-outputs-to some-target (echo some-target))))) | ||
> EOF | ||
|
||
$ dune build | ||
A | ||
File "dune", line 1, characters 0-163: | ||
1 | (rule | ||
2 | (action | ||
3 | (conc | ||
4 | (progn (echo "A\n")) | ||
5 | (progn (system "exit 1") (echo B)) | ||
6 | (progn (echo "C\n")) | ||
7 | (with-outputs-to some-target (echo some-target))))) | ||
Command exited with code 1. | ||
C | ||
[1] | ||
|
||
As you can see, even though C occurs after the failing action for B, it still | ||
runs due to concurrency. |
Oops, something went wrong.