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

How to handle permissions? #140

Closed
milesj opened this issue Dec 23, 2021 · 8 comments
Closed

How to handle permissions? #140

milesj opened this issue Dec 23, 2021 · 8 comments

Comments

@milesj
Copy link

milesj commented Dec 23, 2021

First off, great library.

I'm trying to test my CLI commands that modify the file system, but the tests get a permission denied error, while I'm able to run it locally just fine. Is there anyway to support this?

@epage
Copy link
Contributor

epage commented Dec 23, 2021

I think some more context is needed to be able to help with what you are doing. Where you are writing to and how you are doing it are important factors.

In case you weren't aware, I tend to use https://github.com/assert-rs/assert_fs or https://github.com/assert-rs/trycmd for creating a scratchpad to write to.

@milesj
Copy link
Author

milesj commented Dec 23, 2021

@epage Not using either of those for this specific test, which is this: https://github.com/milesj/monolith/pull/5/files#diff-9a1f0aa2064ff70580494869ae0fa8a4f7c3e9b26cf3eabdfee35a0d6b17baf7R6-R9

I want to test that this code, which the CLI runs, actually works in a real world use case: https://github.com/milesj/monolith/blob/master/crates/toolchain/src/tools/node.rs#L189-L215 Right now I either get a "Permission denied" or "No such file or directory" error.

@epage
Copy link
Contributor

epage commented Dec 23, 2021

Under what conditions do you get each of those errors?

Is this local, CI, or both?

What platforms are you seeing the failure? Know of platforms that work?

btw this is most likely a very specific setup failure or a program bug. I'd recommend tracing in to see which call is failing and verifying the inputs to that call and make sure you are reproducing with those same inputs.

@milesj
Copy link
Author

milesj commented Dec 23, 2021

@epage It fails locally and in CI, for both mac/linux.

I'll try and trace to debug more.

@milesj
Copy link
Author

milesj commented Dec 25, 2021

@milesj I think I found the problem, but it does bring up a question. Does assert() wait for the entire child process to complete? Because this test could take many seconds.

Is there a way to write these in an async/await fashion?

@epage
Copy link
Contributor

epage commented Dec 25, 2021

Yes, this is for one-shot testing rather than interactive testing, so it waits for the program to finish.

@milesj
Copy link
Author

milesj commented Dec 31, 2021

This is still happening, but I've narrowed it down to this line: https://github.com/milesj/moon/blob/master/crates/toolchain/src/helpers.rs#L78

It seems like the dirs aren't being created on line 71 and I have no idea why.

This is the entire test https://github.com/milesj/moon/pull/5/files#diff-a31902d06ac6afdddf64feb76dc589f59e39a33434c352de60ba84f8beca4427R16

@milesj
Copy link
Author

milesj commented May 22, 2022

Not sure what changed, but this isn't an issue anymore. Closing.

@milesj milesj closed this as completed May 22, 2022
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

No branches or pull requests

2 participants