forked from conan-io/conan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests maintenance, fix some xfail, remove other xfails (conan-io#15234)
remove xfail
- Loading branch information
1 parent
e6aa291
commit 37573ee
Showing
10 changed files
with
140 additions
and
1,196 deletions.
There are no files selected for viewing
459 changes: 0 additions & 459 deletions
459
conans/test/integration/build_requires/build_requires_test.py
Large diffs are not rendered by default.
Oops, something went wrong.
90 changes: 21 additions & 69 deletions
90
conans/test/integration/command/export/export_dirty_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,41 @@ | ||
import os | ||
import platform | ||
import textwrap | ||
import unittest | ||
|
||
import pytest | ||
|
||
from conans.model.recipe_ref import RecipeReference | ||
from conans.test.assets.genconanfile import GenConanfile | ||
from conans.test.utils.tools import TestClient | ||
from conans.util.files import load | ||
|
||
|
||
@pytest.mark.xfail(reason="cache2.0") | ||
class SourceDirtyTest(unittest.TestCase): | ||
class TestSourceDirty: | ||
def test_keep_failing_source_folder(self): | ||
# https://github.com/conan-io/conan/issues/4025 | ||
client = TestClient() | ||
conanfile = textwrap.dedent("""\ | ||
from conan import ConanFile | ||
from conans.tools import save | ||
from conan.tools.files import save | ||
class Pkg(ConanFile): | ||
def source(self): | ||
save("somefile.txt", "hello world!!!") | ||
save(self, "somefile.txt", "hello world!!!") | ||
raise Exception("boom") | ||
""") | ||
client.save({"conanfile.py": conanfile}) | ||
client.run("create . --name=pkg --version=1.0 --user=user --channel=channel", assert_error=True) | ||
self.assertIn("ERROR: pkg/1.0@user/channel: Error in source() method, line 6", client.out) | ||
ref = RecipeReference.loads("pkg/1.0@user/channel") | ||
client.run("create . --name=pkg --version=1.0", assert_error=True) | ||
assert "ERROR: pkg/1.0: Error in source() method, line 6" in client.out | ||
# Check that we can debug and see the folder | ||
self.assertEqual(load(os.path.join(client.get_latest_ref_layout(ref).source(), | ||
"somefile.txt")), | ||
"hello world!!!") | ||
client.run("create . --name=pkg --version=1.0 --user=user --channel=channel", assert_error=True) | ||
self.assertIn("pkg/1.0@user/channel: Source folder is corrupted, forcing removal", | ||
client.out) | ||
source_file = os.path.join(client.exported_layout().source(), "somefile.txt") | ||
assert load(source_file) == "hello world!!!" | ||
# Without any change, the export will generate same recipe revision, reuse source folder | ||
client.run("create . --name=pkg --version=1.0", assert_error=True) | ||
assert "pkg/1.0: Source folder is corrupted, forcing removal" in client.out | ||
assert "ERROR: pkg/1.0: Error in source() method, line 6" in client.out | ||
|
||
# The install also removes corrupted source folder before proceeding, then call source | ||
client.run("install --requires=pkg/1.0 --build=missing", assert_error=True) | ||
assert "pkg/1.0: WARN: Trying to remove corrupted source folder" in client.out | ||
assert "ERROR: pkg/1.0: Error in source() method, line 6" in client.out | ||
|
||
# This creates a new revision that doesn't need removal, different source folder | ||
client.save({"conanfile.py": conanfile.replace("source(", "source2(")}) | ||
client.run("create . --name=pkg --version=1.0 --user=user --channel=channel") | ||
self.assertIn("pkg/1.0@user/channel: Source folder is corrupted, forcing removal", | ||
client.out) | ||
client.run("create . --name=pkg --version=1.0") | ||
assert "corrupted, forcing removal" not in client.out | ||
# Check that it is empty | ||
self.assertEqual(os.listdir(os.path.join(client.get_latest_ref_layout(ref).source())), []) | ||
|
||
|
||
@pytest.mark.skipif(platform.system() != "Windows", reason="Needs windows for rmdir block") | ||
@pytest.mark.xfail(reason="cache2.0: revisit tests") | ||
class ExportDirtyTest(unittest.TestCase): | ||
""" Make sure than when the source folder becomes dirty, due to a export of | ||
a new recipe with a rmdir failure, or to an uncomplete execution of source(), | ||
it is marked as dirty and removed when necessary | ||
""" | ||
|
||
def setUp(self): | ||
self.client = TestClient() | ||
self.client.save({"conanfile.py": GenConanfile().with_exports("main.cpp"), | ||
"main.cpp": ""}) | ||
self.client.run("create . --name=pkg --version=0.1 --user=user --channel=stable") | ||
ref = RecipeReference.loads("pkg/0.1@user/stable") | ||
source_path = self.client.get_latest_ref_layout(ref).source() | ||
file_open = os.path.join(source_path, "main.cpp") | ||
|
||
self.f = open(file_open, 'wb') | ||
self.f.write(b"Hello world") | ||
|
||
self.client.save({"conanfile.py": GenConanfile().with_exports("main.cpp", "other.h"), | ||
"main.cpp": ""}) | ||
self.client.run("export . --name=pkg --version=0.1 --user=user --channel=stable") | ||
self.assertIn("ERROR: Unable to delete source folder. " | ||
"Will be marked as corrupted for deletion", | ||
self.client.out) | ||
|
||
self.client.run("install --requires=pkg/0.1@user/stable --build", assert_error=True) | ||
self.assertIn("ERROR: Unable to remove source folder", self.client.out) | ||
|
||
def test_export_remove(self): | ||
# export is able to remove dirty source folders | ||
self.f.close() | ||
self.client.run("export . --name=pkg --version=0.1 --user=user --channel=stable") | ||
self.assertIn("Source folder is corrupted, forcing removal", self.client.out) | ||
self.client.run("install --requires=pkg/0.1@user/stable --build") | ||
self.assertNotIn("WARN: Trying to remove corrupted source folder", self.client.out) | ||
|
||
def test_install_remove(self): | ||
# install is also able to remove dirty source folders | ||
# Now, release the handle to the file | ||
self.f.close() | ||
self.client.run("install --requires=pkg/0.1@user/stable --build") | ||
self.assertIn("WARN: Trying to remove corrupted source folder", self.client.out) | ||
assert os.listdir(os.path.join(client.exported_layout().source())) == [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 40 additions & 89 deletions
129
conans/test/integration/conanfile/no_copy_source_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,45 @@ | ||
import os | ||
import unittest | ||
import textwrap | ||
|
||
import pytest | ||
|
||
from conans.model.recipe_ref import RecipeReference | ||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
class NoCopySourceTest(unittest.TestCase): | ||
|
||
def test_basic(self): | ||
conanfile = ''' | ||
from conan import ConanFile | ||
from conan.tools.files import copy | ||
from conans.util.files import save, load | ||
import os | ||
class ConanFileToolsTest(ConanFile): | ||
name = "pkg" | ||
version = "0.1" | ||
exports_sources = "*" | ||
no_copy_source = True | ||
def build(self): | ||
self.output.info("Source files: %s" % load(os.path.join(self.source_folder, "file.h"))) | ||
save("myartifact.lib", "artifact contents!") | ||
def package(self): | ||
copy(self, "*", self.source_folder, self.package_folder) | ||
copy(self, "*", self.build_folder, self.package_folder) | ||
''' | ||
|
||
client = TestClient() | ||
client.save({"conanfile.py": conanfile, | ||
"file.h": "myfile.h contents"}) | ||
client.run("export . --user=lasote --channel=testing") | ||
client.run("install --requires=pkg/0.1@lasote/testing --build='*'") | ||
self.assertIn("Source files: myfile.h contents", client.out) | ||
ref = RecipeReference.loads("pkg/0.1@lasote/testing") | ||
|
||
latest_rrev = client.cache.get_latest_recipe_reference(ref) | ||
pkg_ids = client.cache.get_package_references(latest_rrev) | ||
latest_prev = client.cache.get_latest_package_reference(pkg_ids[0]) | ||
layout = client.cache.pkg_layout(latest_prev) | ||
build_folder = layout.build() | ||
package_folder = layout.package() | ||
|
||
self.assertNotIn("file.h", os.listdir(build_folder)) | ||
self.assertIn("file.h", os.listdir(package_folder)) | ||
self.assertIn("myartifact.lib", os.listdir(package_folder)) | ||
|
||
@pytest.mark.xfail(reason="cache2.0 create --build not considered yet") | ||
def test_source_folder(self): | ||
conanfile = ''' | ||
from conan import ConanFile | ||
from conans.util.files import save, load | ||
from conan.tools.files import copy | ||
import os | ||
class ConanFileToolsTest(ConanFile): | ||
name = "pkg" | ||
version = "0.1" | ||
no_copy_source = %s | ||
def source(self): | ||
save("header.h", "artifact contents!") | ||
def package(self): | ||
copy(self, "*.h", self.source_folder, os.path.join(self.package_folder, "include")) | ||
''' | ||
client = TestClient() | ||
client.save({"conanfile.py": conanfile % "True"}) | ||
client.run("create . --user=lasote --channel=testing --build") | ||
ref = RecipeReference.loads("pkg/0.1@lasote/testing") | ||
|
||
latest_rrev = client.cache.get_latest_recipe_reference(ref) | ||
latest_prev = client.cache.get_latest_package_reference(latest_rrev) | ||
layout = client.cache.pkg_layout(latest_prev) | ||
package_folder = layout.package() | ||
|
||
self.assertIn("header.h", os.listdir(package_folder)) | ||
|
||
client = TestClient() | ||
client.save({"conanfile.py": conanfile % "False"}) | ||
client.run("create . --user=lasote --channel=testing --build") | ||
ref = RecipeReference.loads("pkg/0.1@lasote/testing") | ||
|
||
latest_rrev = client.cache.get_latest_recipe_reference(ref) | ||
latest_prev = client.cache.get_latest_package_reference(latest_rrev) | ||
layout = client.cache.pkg_layout(latest_prev) | ||
package_folder = layout.package() | ||
|
||
self.assertIn("header.h", os.listdir(package_folder)) | ||
def test_no_copy_source(): | ||
conanfile = textwrap.dedent(''' | ||
from conan import ConanFile | ||
from conan.tools.files import copy, save, load | ||
import os | ||
class ConanFileToolsTest(ConanFile): | ||
name = "pkg" | ||
version = "0.1" | ||
exports_sources = "*" | ||
no_copy_source = True | ||
def source(self): | ||
save(self, "header.h", "artifact contents!") | ||
def build(self): | ||
self.output.info("Source files: %s" % load(self, | ||
os.path.join(self.source_folder, "file.h"))) | ||
save(self, "myartifact.lib", "artifact contents!") | ||
def package(self): | ||
copy(self, "*", self.source_folder, self.package_folder) | ||
copy(self, "*", self.build_folder, self.package_folder) | ||
''') | ||
|
||
client = TestClient() | ||
client.save({"conanfile.py": conanfile, | ||
"file.h": "myfile.h contents"}) | ||
client.run("create .") | ||
assert "Source files: myfile.h contents" in client.out | ||
layout = client.created_layout() | ||
build_folder = layout.build() | ||
package_folder = layout.package() | ||
|
||
assert "file.h" not in os.listdir(build_folder) | ||
assert "header.h" not in os.listdir(build_folder) | ||
assert "file.h" in os.listdir(package_folder) | ||
assert "header.h" in os.listdir(package_folder) | ||
assert "myartifact.lib" in os.listdir(package_folder) |
59 changes: 0 additions & 59 deletions
59
conans/test/integration/configuration/conan_trace_file_test.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.