added new test to show local patch in source()
import unittest
-from conans.errors import ConanException
from conans.paths import CONANFILE, BUILD_INFO
from conans.test.utils.tools import TestClient
from conans.util.files import load, mkdir
@@ -8,6 +7,28 @@ import os
class SourceTest(unittest.TestCase):
+ def apply_patch_test(self):
+ # https://github.com/conan-io/conan/issues/2327
+ # Test if a patch can be applied in source() both in create
+ # and local flow
+ client = TestClient()
+ conanfile = """from conans import ConanFile
+from conans.tools import load
+import os
+class Pkg(ConanFile):
+ exports_sources = "*"
+ def source(self):
+ if self.develop:
+ patch = os.path.join(self.source_folder, "mypatch")
+ self.output.info("PATCH: %s" % load(patch))
+"""
+ client.save({"conanfile.py": conanfile,
+ "mypatch": "this is my patch"})
+ client.run("source .")
+ self.assertIn("PATCH: this is my patch", client.out)
+ client.run("create . Pkg/0.1@user/testing")
+ self.assertIn("PATCH: this is my patch", client.out)
+
def source_reference_test(self):
client = TestClient()
error = client.run("source lib/1.0@conan/stable", ignore_error=True)
@@ -122,7 +143,6 @@ class ConanLib(ConanFile):
self.output.info("MYVAR=%s" % self.deps_env_info["Hello"].MYVAR)
self.output.info("OTHERVAR=%s" % self.deps_user_info["Hello"].OTHERVAR)
self.output.info("CURDIR=%s" % os.getcwd())
-
'''
# First, failing source()
client.save({CONANFILE: conanfile}, clean_first=True)
