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

idris_support: fix environ for macOS #3324

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

barracuda156
Copy link
Contributor

Description

Fix environ for Apple: this version works on every macOS, unlike the generic one.

Copy link
Collaborator

@mattpolzin mattpolzin left a comment

Choose a reason for hiding this comment

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

This looks good to me. Do you mind adding a really simple test to tests/base that exercises getEnvironment in Idris which in turn relies on the environ variable? If you'd like some pointers on adding new tests, just let me know.

@barracuda156
Copy link
Contributor Author

@mattpolzin
Copy link
Collaborator

mattpolzin commented Jun 24, 2024

Idris uses golden tests that are automatically discovered (for the test directory we are concerned about) so the easiest thing to do is copy an existing test and modify.

I'd recommend copying tests/base/system_env to tests/base/system_get_environment as a starting place.

Next, delete the expected file (you'll generate a new one when running the test after modifying the copied folder).

In the run file, you can delete the comment and also the second invocation of idris2 (getEnvironment does not support the Node backend at the moment).

In Test.idr, you can replace just about everything. Since we can't rely on the full list of environment variables being the same in every environment, I suggest simply checking that the list of variables is not empty in the test. You can just print out "good" or "bad" depending on success (or any number of other strategies for indicating success) because the golden test will pass if the output is the same and fail if it is different.

Then, to generate a value for your test, run the following from the root of the repo:

make test only=system_get_environment

You'll see "Golden value missing..." and it should suggest the expected success result to you. Type y and hit enter to accept the value. It'll indicate tests failed, but if you immediately re-run the test command, you'll see it succeeds.

@mattpolzin
Copy link
Collaborator

Depending on your familiarity with the Idris2 language itself, I may or may not have left you with some things to puzzle through. Feel free to ask if you're just getting started with programming in Idris and haven't yet worked out how to write IO do blocks.

@mattpolzin
Copy link
Collaborator

Your change here definitely looks good to go, so I hope you don't mind that I pushed up that new test I was suggesting myself. We can get this merged once CI finishes.

@mattpolzin mattpolzin merged commit 1931509 into idris-lang:main Jul 3, 2024
22 checks passed
@barracuda156
Copy link
Contributor Author

@mattpolzin Thank you very much! And sorry that I did not return to test issue, too much stuff to handle, and I am not familiar with the language syntax here, so need to read documentation first to do anything.

@barracuda156 barracuda156 deleted the environ branch July 5, 2024 04:03
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