Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add format stdin smoke tests #2019

Merged
merged 2 commits into from
Apr 21, 2023
Merged

Add format stdin smoke tests #2019

merged 2 commits into from
Apr 21, 2023

Conversation

vrom911
Copy link
Contributor

@vrom911 vrom911 commented Apr 20, 2023

As I were trying to fix the behaviour of format command with the --stdin global option, I noticed that actually it is already behaves the same was as dev scope command (which was the desire at least at this point).

So, no actual behaviour of the command is channged, only a few tests added to showcase some edge cases of the command with the --stdin option together.

Here are the highlights:

  • The filename is not optional for both dev scope and format even if with stdin the content of the file comes from the input.
  • format command expects the stdin input to be a proper module
  • the name of the stdin module should be aligned with the provided filename even though its sources are not used

I think that some of the above behaviours we can consider to change. Let me know what do you think about any of that.

Otherwise, the dev scope command can be replaced with format.

@@ -8,7 +8,7 @@ axiom trace : {A : Type} → A → A;

terminating
f : Nat → Nat → Nat;
f x y := if (x == 0) y (trace x >>> (f (sub x 1) y));
f x y := if (x == 0) y (trace x >>> f (sub x 1) y);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curiosity, did you change this manually? or it was the formatter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is after make pre-commit command work, not sure how it was not caught earlier

Copy link
Collaborator

Choose a reason for hiding this comment

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

Exactly. pre-commit locally runs the Juvix formatter and the CI as well. I'm supprised, a new mystery to my stack.

@jonaprieto
Copy link
Collaborator

Is this ready to review or is it a draft? I just rebased it because the CI failed to build the project.

@vrom911
Copy link
Contributor Author

vrom911 commented Apr 20, 2023

@jonaprieto ye, this PR only adds tests. I am working on what we discussed today, which is handling the command without filepath but with stdin better.

Regarding failing tests, locally, my tests are passing. It seem to be different behaviour possibly due to the Linux machine run? Not sure that this is the only reason for failure

@vrom911 vrom911 temporarily deployed to github-pages April 21, 2023 10:41 — with GitHub Actions Inactive
@vrom911
Copy link
Contributor Author

vrom911 commented Apr 21, 2023

As figured out, I somehow used the older version of the juvix locally, the one of a week before, that is why the previous difference with local vs CI testing output.

Can confirm, that currently the format command for sure doesn't fail or throw ErrWrongTopModuleName anymore. This solves the inconvenience with the --stdin command, however, still it is better to not require the filename when intended to use with --stdin. Currently working on that.

Also, I wonder what the priority should be if you specify both --stdin and the filename ideally?
I would say that reading file should be prioritised over the stdin input in that cases, however, I can see the other way around.
For now, I will keep the --stdin priority as it is, but let me know if we want to change that, and I can create the issue to tackle this problem.

@jonaprieto
Copy link
Collaborator

better to not require the filename when intended to use with --stdin. Currently working on that.

👍

I wonder what the priority should be if you specify both --stdin and the filename ideally?

Based on the usage case, that is the vscode extension, I'd keep giving priority to --stdin input.

@jonaprieto jonaprieto removed the request for review from paulcadman April 21, 2023 11:24
@jonaprieto jonaprieto merged commit 89d7422 into main Apr 21, 2023
@jonaprieto jonaprieto deleted the vrom911/2008-format-stdin branch April 21, 2023 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants