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

fix conan_home_folder windows backslash #15870

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conan/api/subapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def load_config(home_folder):
if platform.system() in ["Linux", "FreeBSD"]:
import distro
template = Environment(loader=FileSystemLoader(home_folder)).from_string(text)
home_folder = home_folder.replace("\\", "/")
content = template.render({"platform": platform, "os": os, "distro": distro,
"conan_version": conan_version,
"conan_home_folder": home_folder,
Expand Down
13 changes: 11 additions & 2 deletions conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ def package_info(self):
assert "set(CMAKE_SYSTEM_PROCESSOR ARM-POTATO)" in toolchain


def test_inject_user_toolchain_profile():
def test_inject_user_toolchain():
client = TestClient()

conanfile = textwrap.dedent("""
Expand Down Expand Up @@ -1509,9 +1509,18 @@ def build(self):
save(os.path.join(client.cache.profiles_path, "myvars.cmake"), 'set(MY_USER_VAR1 "MYVALUE1")')
client.save({"conanfile.py": conanfile,
"CMakeLists.txt": cmake})
client.run("create . -pr=myprofile")
client.run("build . -pr=myprofile")
assert "-- MYVAR1 MYVALUE1!!" in client.out

# Now test with the global.conf
global_conf = 'tools.cmake.cmaketoolchain:user_toolchain=' \
'["{{conan_home_folder}}/my.cmake"]'
save(client.cache.new_config_path, global_conf)
save(os.path.join(client.cache_folder, "my.cmake"), 'message(STATUS "IT WORKS!!!!")')
client.run("build .")
# The toolchain is found and can be used
assert "IT WORKS!!!!" in client.out


def test_no_build_type():
client = TestClient()
Expand Down
3 changes: 2 additions & 1 deletion conans/test/integration/configuration/conf/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def test_jinja_global_conf_paths():
global_conf = 'user.mycompany:myfile = {{os.path.join(conan_home_folder, "myfile")}}'
save(c.cache.new_config_path, global_conf)
c.run("config show *")
assert f"user.mycompany:myfile: {os.path.join(c.cache_folder, 'myfile')}" in c.out
cache_folder = c.cache_folder.replace("\\", "/")
assert f"user.mycompany:myfile: {os.path.join(cache_folder, 'myfile')}" in c.out


def test_profile_detect_os_arch():
Expand Down