Skip to content

Add pipe actions#3392

Merged
NathanReb merged 7 commits intoocaml:masterfrom
NathanReb:pipe-actions
Jun 9, 2020
Merged

Add pipe actions#3392
NathanReb merged 7 commits intoocaml:masterfrom
NathanReb:pipe-actions

Conversation

@NathanReb
Copy link
Copy Markdown
Collaborator

Fixes #428

This PR introduces pipe-outputs, pipe-stdout and pipe-stderr to the action language.

The tests don't cover much atm. In particular I'd like to make sure I got the Action_to_sh part right but I'm unsure what's the best way to test it.

I also believe I need to fix the stdout/stderr-only cases by adding a multi_use to the one that's not being piped.

@NathanReb NathanReb requested review from a user and rgrinberg April 20, 2020 09:33
@NathanReb NathanReb requested review from emillon and nojb as code owners April 20, 2020 09:33
@NathanReb NathanReb force-pushed the pipe-actions branch 2 times, most recently from 3b7c22a to b804a1d Compare April 20, 2020 09:46
@ghost
Copy link
Copy Markdown

ghost commented Apr 20, 2020

@NathanReb is this ready for review? If not, could you add [WIP] in the title?

@NathanReb
Copy link
Copy Markdown
Collaborator Author

To be honest I'm not even sure myself, I'll try to add the multi_use but then it should be ready for review!

@NathanReb NathanReb changed the title Add pipe actions [WIP] Add pipe actions Apr 21, 2020
@NathanReb
Copy link
Copy Markdown
Collaborator Author

I added the proper multi_use channels and also added a test for the shell conversion.

If you look at that test you'll note that the shell conversion of echo doesn't seem to work very well. Also it seems that the shell conversions swallow quotes when they shouldn't.

I'll propabaly change that test so that it doesn't depend on echo and run to be properly converted but we should look into fixing those!

@NathanReb NathanReb changed the title [WIP] Add pipe actions Add pipe actions Apr 21, 2020
@NathanReb
Copy link
Copy Markdown
Collaborator Author

I just pushed a commit to simplify the shell conversion test so if you want to see the bugs I mentioned you should take a look at this.

@NathanReb
Copy link
Copy Markdown
Collaborator Author

Ok it seems like it didn't swallow single quotes when translating (run grep "'a\\|b'"). I just did not promote the last change.

The bug with echo is real though!

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a couple of tweaks regarding the handling of the temporary files, but otherwise looks good.

and exec_pipe outputs ts ~ectx ~eenv =
let tmp_file () =
Path.of_string
(Filename.temp_file "pipe-action-"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In process.ml, there is a Temp sub-module that ensures that temporary files are deleted in case of abnormal exit. We should extract it to reuse it here.

@ghost
Copy link
Copy Markdown

ghost commented Apr 28, 2020

This makes me think that we should improvement our management of temporary files: #3432

@rgrinberg rgrinberg marked this pull request as draft April 28, 2020 22:26
@NathanReb NathanReb force-pushed the pipe-actions branch 2 times, most recently from 905be52 to 9a0c240 Compare April 29, 2020 13:27
@NathanReb
Copy link
Copy Markdown
Collaborator Author

I just rebased and fixed the conflicts!

I'm guessing I should fix the temp file mgmt issue first in a separate PR or is it okay to do it here?

@ghost
Copy link
Copy Markdown

ghost commented Apr 29, 2020

A separate PR is better

@NathanReb NathanReb mentioned this pull request Jun 2, 2020
@NathanReb NathanReb force-pushed the pipe-actions branch 2 times, most recently from ae7434e to 25d64c1 Compare June 2, 2020 12:19
@NathanReb
Copy link
Copy Markdown
Collaborator Author

I just rebased on top of #3521 and slightly improved the tmp file management for pipe actions by deleting intermediate files as it goes.

@NathanReb NathanReb marked this pull request as ready for review June 2, 2020 15:58
@NathanReb NathanReb force-pushed the pipe-actions branch 2 times, most recently from 5fb7969 to e60240a Compare June 8, 2020 09:39
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all good!

NathanReb and others added 7 commits June 9, 2020 15:30
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Use tr instead of grep:
- avoid some nasty quoting
- it's easier to observe the effect of transformations

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
@NathanReb NathanReb merged commit 9b88e94 into ocaml:master Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input redirection and pipes

2 participants