muter icon indicating copy to clipboard operation
muter copied to clipboard

Change temporary directory

Open uncle-alek opened this issue 3 years ago • 20 comments

Why:

projects that use resources with relative paths cannot be built

What was done:

  1. New flag has been added to the configuration Screen Shot 2022-09-09 at 18 26 15

  2. CopyProjectToTempDirectory step was split into 2 steps: CopyProjectToTempDirectory and CreateTempDirectoryURL

  3. RemoveProjectFromPreviousRun step has been added

The default steps: Screen Shot 2022-09-09 at 18 30 33

uncle-alek avatar Sep 02 '22 14:09 uncle-alek

@uncle-alek could you elaborate on the issue little more? it's not clear to me why adding _mutated at the end fixes it nor what really is the bug

rakaramos avatar Sep 02 '22 20:09 rakaramos

It makes sense to me. A project may require resources outside itself, but relative to its own path, in order to build. Keeping the mutated project in the same folder as the original ensures that those relative paths will still work.

ZevEisenberg avatar Sep 02 '22 22:09 ZevEisenberg

@rakaramos sorry for the poor explanation of the issue, @ZevEisenberg explained it very well. This happens with a large project with many submodules (subprojects) that reuse resources.

uncle-alek avatar Sep 03 '22 07:09 uncle-alek

Should a temporary directory be kept on disk for any use? I just found the Muter output message: This directory will also serve as a backup for any XCTest logs that are generated by running your test suite.

uncle-alek avatar Sep 03 '22 07:09 uncle-alek

yes @uncle-alek, we have a folder for dumping all the logs, for troubleshooting in case something goes wrong

rakaramos avatar Sep 03 '22 10:09 rakaramos

Should a temporary directory be kept on disk for any use? I just found the Muter output message: This directory will also serve as a backup for any XCTest logs that are generated by running your test suite.

We are saving the logs at the current path

https://github.com/muter-mutation-testing/muter/blob/f24315a287e929ca92eed476f506fa983239eafc/Sources/muterCore/MutationTesting/MutationTestingIODelegate.swift#L57

If you are still seeing muter_logs on the project's directory, after muter finished, then I think it's fine!

rakaramos avatar Sep 03 '22 12:09 rakaramos

Should a temporary directory be kept on disk for any use? I just found the Muter output message: This directory will also serve as a backup for any XCTest logs that are generated by running your test suite.

We are saving the logs at the current path

https://github.com/muter-mutation-testing/muter/blob/f24315a287e929ca92eed476f506fa983239eafc/Sources/muterCore/MutationTesting/MutationTestingIODelegate.swift#L57

If you are still seeing muter_logs on the project's directory, after muter finished, then I think it's fine!

I still see it in the project directory, but it looks like this message (This directory will also serve as a backup for any XCTest logs that are generated by running your test suite) is no longer relevant.

uncle-alek avatar Sep 03 '22 13:09 uncle-alek

And this one You can find your copied project here.

uncle-alek avatar Sep 03 '22 13:09 uncle-alek

@rakaramos regressions tests passed Screen Shot 2022-09-04 at 08 21 21

uncle-alek avatar Sep 04 '22 01:09 uncle-alek

What do you think about making this a flag/option instead of the default behavior? I'm wary of creating new files outside the project directory, especially ones that aren't in a temp folder so they won't get cleaned up on reboot. I think the utility of this change is definitely valid, but also probably not that common of a need.

ZevEisenberg avatar Sep 04 '22 01:09 ZevEisenberg

@ZevEisenberg i'm thinking about the name of this flag and I think the user of the muter could be confused if he sees something like useProjectDirectoryForMutation. Should the flag be part of the conf.json file?

uncle-alek avatar Sep 04 '22 08:09 uncle-alek

What if pass the path to copy the project in the configuration? Default will be the temp one.

uncle-alek avatar Sep 04 '22 09:09 uncle-alek

I agree with adding it to the json config, seems to be more of a project configuration that won't change than something users would tweak on each run

rakaramos avatar Sep 04 '22 09:09 rakaramos

mutateFilesInSiblingOfProjevtFolder maybe? And just a Boolean - probably don't need to pass a path unless we get more use cases that people actually need.

ZevEisenberg avatar Sep 04 '22 14:09 ZevEisenberg

But also, I think I'm used to CLIs allowing both config file and command line flags, just for flexibility.

ZevEisenberg avatar Sep 04 '22 14:09 ZevEisenberg

I added the flag to the config. An additional step is also provided to clean up the temp folder if any step throws an error.

uncle-alek avatar Sep 05 '22 14:09 uncle-alek

What if the user needs to keep the temp folder around to debug the failure?

ZevEisenberg avatar Sep 05 '22 16:09 ZevEisenberg

I think in this case, the temporary folder can be saved and deleted the next time you start the muter. But the user will have to add the folder name to the .gitignore file.

Current steps:

...
CopyProjectToTempDirectory
...
RemoveTempDirectory

After:

...
RemoveTempDirectory
CopyProjectToTempDirectory
...

uncle-alek avatar Sep 05 '22 22:09 uncle-alek

@rakaramos @ZevEisenberg sorry forgot to mention all regression tests passed, could you double check the code?

Screen Shot 2022-09-14 at 09 40 39

uncle-alek avatar Sep 14 '22 02:09 uncle-alek

@rakaramos @ZevEisenberg sorry to bother you again, just want to remind you of the opened PR :)

uncle-alek avatar Sep 23 '22 13:09 uncle-alek