conan icon indicating copy to clipboard operation
conan copied to clipboard

[question] conan2: How to make path to test shorter?

Open Nekto89 opened this issue 1 year ago • 4 comments

What is your question?

Hi, I have problem with conan2. Path to folder with test_package/conanfile.py is 126 symbols and MSVC compiler can't work with long pathes on Windows yet even with enabled option. Is there some option that will tell conan2 (create/test) to use some other directory for tests? Conan1 had "--test-build-folder" but I don't see it in conan2.

FileTracker : error FTK1011: could not create the new file tracking log file: <longpath>\test_package\build\msvc-192-x86_64-17-release\CMakeFiles\CMakeScratch\TryCompile-kf0gqn\cmTC_8460c.dir\Debug\cmTC_8460c.tlog\link.50124-rc.read.1.tlog. The system cannot find the path specified. [<longpath>\test_package\build\msvc-192-x86_64-17-release\CMakeFiles\CMakeScratch\TryCompile-kf0gqn\cmTC_8460c.vcxproj] [....vcxproj]

Have you read the CONTRIBUTING guide?

  • [X] I've read the CONTRIBUTING guide

Nekto89 avatar Feb 14 '24 11:02 Nekto89

Hi @Nekto89 thanks a lot for your question.

Every command that runs tests has this possible arguments, which seem to me like what you are after:

-tf TEST_FOLDER, --test-folder TEST_FOLDER
                        Alternative test folder name. By default it is "test_package". Use "" to skip the
                        test stage
  -bt BUILD_TEST, --build-test BUILD_TEST
                        Same as '--build' but only for the test_package requires. By default if not
                        specified it will take the '--build' value if specified

Let me know if that helps :)

AbrilRBS avatar Feb 14 '24 11:02 AbrilRBS

Hi @Nekto89 thanks a lot for your question.

Every command that runs tests has this possible arguments, which seem to me like what you are after:

-tf TEST_FOLDER, --test-folder TEST_FOLDER
                        Alternative test folder name. By default it is "test_package". Use "" to skip the
                        test stage
  -bt BUILD_TEST, --build-test BUILD_TEST
                        Same as '--build' but only for the test_package requires. By default if not
                        specified it will take the '--build' value if specified

Let me know if that helps :)

If I understood correctly, -tf allows to use another folder with test conanfile.py. I would like to build and run tests, but with default location I have a problem. So I want to change root path of folder where conan will put CMakePresets.json and create all the structure "build\msvc-192-x86_64-17-release....". As a workaround, I can probably copy test_package to some temp folder before running conan but maybe there is some better way?

Nekto89 avatar Feb 14 '24 11:02 Nekto89

I'll let @memsharded chime in with further insight into why the Conan v1 feature was not ported over for v2 :)

AbrilRBS avatar Feb 16 '24 00:02 AbrilRBS

The problem with the Conan 1.X feature was that moving to another folder with an argument also creates a bunch of issues, when running things in parallel or just by caching. Consider:

conan create . --test-build-folder=C:/mytestsfolder

Then every single conan create for every different package will be trying to write to C:\mytestfolder\test_package\build\msvc-192-x86_64-17-release, causing lots of issues! Then users should be doing something like

random_uuid = ....
conan create . --test-build-folder=C:/mytestsfolder/${randomuuid}

this might be doable in CI, but in developers machines would be a pain.

The most pragmatic approach is avoiding altogether having an initial root path that it is too long. At the end of the day Conan is only using test_package\build\release in most cases (the long msvc-192-x86_64-17-release is optional by the user), and those are not many characters.

I am not saying we don't want to consider another approach or solution, just saying that the 1.X also had its own downsides.

memsharded avatar Feb 16 '24 16:02 memsharded