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

Remove old folder for conan install (#5376) #5384

Merged
merged 4 commits into from
Jun 28, 2019
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 conans/client/conf/config_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def tmp_config_install_folder(cache):
tmp_folder = os.path.join(cache.cache_folder, "tmp_config_install")
# necessary for Mac OSX, where the temp folders in /var/ are symlinks to /private/var/
tmp_folder = os.path.realpath(tmp_folder)
rmdir(tmp_folder)
mkdir(tmp_folder)
try:
yield tmp_folder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding=utf-8

import unittest
import os

from conans.client.conf.config_installer import tmp_config_install_folder
from conans.test.utils.tools import TestClient


class InstallFolderTests(unittest.TestCase):

def test_unique_install_folder(self):
""" Validate if tmp_config_install_folder is removing old folder before creating a new one

tmp_config_install_folder must create the same folder, but all items must be exclude when a
new folder is created.
"""
client = TestClient()

with tmp_config_install_folder(client.cache) as tmp_folder_first:
temp_file = os.path.join(tmp_folder_first, "foobar.txt")
open(temp_file, "w+")
with tmp_config_install_folder(client.cache) as tmp_folder_second:
uilianries marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(tmp_folder_first, tmp_folder_second)
self.assertFalse(os.path.exists(temp_file))