buffrs icon indicating copy to clipboard operation
buffrs copied to clipboard

Simplify project root detection in tutorial test

Open DavidWHelsing opened this issue 9 months ago • 2 comments

The project source code detection in the tutorial test was using gix to detect root of the rust project by looking for the .git directory. As far as I can tell this is unnecessary since rust tests are always executed from the project root. So the working path should already be the correct directory. Even if the tests were somehow manually executed from a different path I don't think the existing code would have worked since it was joining current working directory with crate::parent_directory!() which would be the relative path of the directory in which our code file is located. That would be incorrect for any other working directory.

This assumption might not work in a cargo workspace but I think that this code would already not work in a workspace and this project isn't using a workspace right now.

Simplifying this code also allows us to remove the dependency on on gix. Since this is a dev dependancy change there should be no need for a version bump

DavidWHelsing avatar May 09 '24 09:05 DavidWHelsing

Seems like the tests pass! Just beware that you now have a clippy error in ci

Also I think this code used to be in there to make cargo test executable in subdirectories / crates

mara-schulke avatar May 10 '24 07:05 mara-schulke

Also I think this code used to be in there to make cargo test executable in subdirectories / crates

I test this and it worked for me. Both using cargo test and cargo nextest run running from a subdirectory. I think they both set cwd to be the project root when executing.

But happy to not merge this if there was a reason why this was added!

ghost avatar May 10 '24 10:05 ghost

@DavidWHelsing please go ahead!! Im happy to accept whatever changes improve code quality while keeping the test passing 😊

mara-schulke avatar Jun 13 '24 20:06 mara-schulke