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 tests for user id and group id #673

Merged
merged 1 commit into from
Mar 18, 2019
Merged

Add tests for user id and group id #673

merged 1 commit into from
Mar 18, 2019

Conversation

anuragsoni
Copy link
Contributor

relates to #539

Signed-off-by: Anurag Soni [email protected]

@anuragsoni anuragsoni mentioned this pull request Mar 15, 2019
35 tasks
@anuragsoni
Copy link
Contributor Author

The MacOS builds failed. I'll try and find out how travis does the setup for it. I don't have access to a Mac but i'd have expected these calls to work there.

@aantron
Copy link
Collaborator

aantron commented Mar 16, 2019

I don't have immediate access to a Mac I can try this on. However, looking at the tests, I think they need to be adjusted.

It looks like all the tests use getlogin to get a user name for testing purposes, and then call the various functions on it. This is reasonable for getpwnam and getpwuid, because those functions expect a user name. However, for getgrnam and getgrgid, you should provide a group name, not a user name. What I suspect is happening is that on Ubuntu in Travis, there is a group with the same name as the user under which the tests are running, but this is not the case in Travis on macOS, and it also won't be the case in general.

@aantron
Copy link
Collaborator

aantron commented Mar 16, 2019

(Respectively, group id and user id for getgrgid and getpwuid).

@anuragsoni
Copy link
Contributor Author

Ah i completely missed that i was using a user login name to retrieve groups. I've updated the tests to use group ids instead. The Not_found exception should have been a hint :)

Lwt.return (pwuid = unix_pwuid)
end;
test "getgrgid and Unix.getgrgid" ~only_if:(fun () -> not Sys.win32) begin fun () ->
let groups = Unix.getgroups () in
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you considered Unix.getgid instead? It looks like it should always return a gid for the test to use, so you don't have to have the pattern-matching below, and a fall-through case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use Unix.getgid instead.

@aantron
Copy link
Collaborator

aantron commented Mar 17, 2019

Happens to us all :)

relates to #539

Signed-off-by: Anurag Soni <[email protected]>
@aantron aantron merged commit a79c1cd into ocsigen:master Mar 18, 2019
@aantron
Copy link
Collaborator

aantron commented Mar 18, 2019

Great, thanks for doing this :)

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.

2 participants