-
Notifications
You must be signed in to change notification settings - Fork 993
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
[DO NOT MERGE] Add tests related to SCM feature (scm_folder and SVN monorepo) #4193
Closed
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fabe36c
add test manifesting bug
jgsogo 1cb9200
add tests related to SVN mono-repo
jgsogo dfe45dd
minor fix
jgsogo 7def39b
modify tests
jgsogo 780b925
preparing tests for several use cases of SCM
jgsogo bb498d1
centralize env vars
jgsogo a6bc944
order imports
jgsogo cfccfc3
typo
jgsogo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# coding=utf-8 | ||
|
||
import os | ||
import textwrap | ||
import unittest | ||
|
||
from parameterized import parameterized | ||
|
||
from conans.client.tools import environment_append | ||
from conans.test.utils.tools import TestClient, create_local_git_repo | ||
|
||
|
||
class SCMFolderGitTest(unittest.TestCase): | ||
conanfile = textwrap.dedent("""\ | ||
import os | ||
from conans import ConanFile, tools | ||
|
||
class Pkg(ConanFile): | ||
scm = {"type": "git", | ||
"url": "auto", | ||
"revision": "auto"} | ||
|
||
def build(self): | ||
content = tools.load(os.path.join(self.source_folder, "file.txt")) | ||
self.output.info(">>>> I'm {}/{}@{}/{}".format(self.name, self.version, | ||
self.user, self.channel)) | ||
self.output.info(">>>> content: {} ".format(content)) | ||
""") | ||
|
||
def run(self, *args, **kwargs): | ||
with environment_append({'CONAN_USERNAME': "user", | ||
'CONAN_CHANNEL': "channel"}): | ||
super(SCMFolderGitTest, self).run(*args, **kwargs) | ||
|
||
def setUp(self): | ||
self.lib1_ref = "lib1/version@user/channel" | ||
self.url, _ = create_local_git_repo(files={'lib1/conanfile.py': self.conanfile, | ||
'lib1/file.txt': self.lib1_ref}) | ||
|
||
def _run_local_test(self, t, working_dir, path_to_conanfile): | ||
old_wd = t.current_folder | ||
try: | ||
t.current_folder = working_dir | ||
t.run("install {} -if tmp".format(path_to_conanfile)) | ||
t.run("source {} -if tmp -sf src".format(path_to_conanfile)) | ||
t.run("build {} -if tmp -sf src -bf build".format(path_to_conanfile)) | ||
self.assertIn(">>>> I'm None/None@user/channel".format(self.lib1_ref), t.out) | ||
self.assertIn(">>>> content: {}".format(self.lib1_ref), t.out) | ||
finally: | ||
t.current_folder = old_wd | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_local_workflow_root_folder(self, use_scm_folder): | ||
with environment_append({'USE_SCM_FOLER': use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner('git clone "{}" .'.format(self.url), cwd=t.current_folder) | ||
|
||
# Local workflow (from root folder) | ||
self._run_local_test(t, t.current_folder, "lib1") | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_local_workflow_inner_folder(self, use_scm_folder): | ||
with environment_append({'USE_SCM_FOLER': use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner('git clone "{}" .'.format(self.url), cwd=t.current_folder) | ||
|
||
# Local workflow (from inner folder) | ||
self._run_local_test(t, os.path.join(t.current_folder, "lib1"), ".") | ||
|
||
def _run_remote_test(self, t, working_dir, path_to_conanfile): | ||
old_wd = t.current_folder | ||
try: | ||
t.current_folder = working_dir | ||
t.run("create {} {}".format(path_to_conanfile, self.lib1_ref)) | ||
self.assertIn(">>>> I'm {}".format(self.lib1_ref), t.out) | ||
self.assertIn(">>>> content: {}".format(self.lib1_ref), t.out) | ||
finally: | ||
t.current_folder = old_wd | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_remote_workflow(self, use_scm_folder): | ||
with environment_append({"USE_SCM_FOLER": use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner('git clone "{}" .'.format(self.url), cwd=t.current_folder) | ||
self._run_remote_test(t, t.current_folder, "lib1") | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_remote_workflow_chdir(self, use_scm_folder): | ||
with environment_append({"USE_SCM_FOLER": use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner('git clone "{}" .'.format(self.url), cwd=t.current_folder) | ||
self._run_remote_test(t, os.path.join(t.current_folder, "lib1"), ".") |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# coding=utf-8 | ||
|
||
import textwrap | ||
import unittest | ||
|
||
from parameterized import parameterized | ||
from conans.test.utils.tools import TestClient, create_local_git_repo | ||
from conans.client.tools import environment_append | ||
|
||
|
||
class SCMFolderObsoleteTest(unittest.TestCase): | ||
conanfile = textwrap.dedent("""\ | ||
from conans import ConanFile, tools | ||
|
||
class Pkg(ConanFile): | ||
scm = {"type": "git", | ||
"url": "auto", | ||
"revision": "auto"} | ||
|
||
def build(self): | ||
content = tools.load("file.txt") | ||
self.output.info(">>>> I'm {}/{}@{}/{}".format(self.name, self.version, | ||
self.user, self.channel)) | ||
self.output.info(">>>> content: {} ".format(content)) | ||
""") | ||
|
||
@parameterized.expand([("True", ), ("False", )]) | ||
def test_obsolete(self, use_scm_folder): | ||
with environment_append({"USE_SCM_FOLER": use_scm_folder}): | ||
reference = "pkg/v1@user/channel" | ||
t = TestClient(path_with_spaces=False) | ||
|
||
# Create pkg/v1 | ||
url, _ = create_local_git_repo(files={'conanfile.py': self.conanfile, | ||
'file.txt': reference}, | ||
folder=t.current_folder) | ||
t.runner('git remote add origin {}'.format(url), cwd=t.current_folder) | ||
t.run("create . {}".format(reference)) | ||
self.assertIn(">>>> I'm {}".format(reference), t.out) | ||
self.assertIn(">>>> content: {}".format(reference), t.out) | ||
|
||
# Work on pkg to improve it ==> create pkg/v2 | ||
ref_v2 = "pkg/v2@user/channel" | ||
t.save(files={'conanfile.py': self.conanfile, | ||
'file.txt': ref_v2}) | ||
t.runner('git commit -a -m "up to v2"', cwd=t.current_folder) | ||
t.run("create . {}".format(ref_v2)) | ||
self.assertIn(">>>> I'm {}".format(ref_v2), t.out) | ||
self.assertIn(">>>> content: {}".format(ref_v2), t.out) | ||
|
||
# Now, a consumer wants the pkg/v1 and builds it... | ||
t.run("install {} --build".format(reference)) | ||
self.assertIn(">>>> I'm {}".format(reference), t.out) | ||
self.assertIn(">>>> content: {}".format(reference), t.out) |
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 |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# coding=utf-8 | ||
|
||
import os | ||
import textwrap | ||
|
||
from nose.plugins.attrib import attr | ||
from parameterized import parameterized | ||
|
||
from conans.client.tools import environment_append | ||
from conans.test.utils.tools import SVNLocalRepoTestCase | ||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
@attr("svn") | ||
class SCMFolderSVNCheckout(SVNLocalRepoTestCase): | ||
conanfile = textwrap.dedent("""\ | ||
import os | ||
from conans import ConanFile, tools | ||
|
||
class Pkg(ConanFile): | ||
scm = {"type": "svn", | ||
"url": "auto", | ||
"revision": "auto"} | ||
|
||
def build(self): | ||
content = tools.load(os.path.join(self.source_folder, "file.txt")) | ||
self.output.info(">>>> I'm {}/{}@{}/{}".format(self.name, self.version, | ||
self.user, self.channel)) | ||
self.output.info(">>>> content: {} ".format(content)) | ||
""") | ||
|
||
def run(self, *args, **kwargs): | ||
with environment_append({'CONAN_USERNAME': "user", | ||
"CONAN_CHANNEL": "channel"}): | ||
super(SCMFolderSVNCheckout, self).run(*args, **kwargs) | ||
|
||
def setUp(self): | ||
self.lib1_ref = "lib1/version@user/channel" | ||
self.lib2_ref = "lib2/version@user/channel" | ||
self.url, _ = self.create_project(files={'lib1/conanfile.py': self.conanfile, | ||
'lib1/file.txt': self.lib1_ref}) | ||
|
||
def _run_local_test(self, t, working_dir, path_to_conanfile): | ||
old_wd = t.current_folder | ||
try: | ||
t.current_folder = working_dir | ||
t.run("install {} -if tmp".format(path_to_conanfile)) | ||
t.run("source {} -if tmp -sf src".format(path_to_conanfile)) | ||
t.run("build {} -if tmp -sf src -bf build".format(path_to_conanfile)) | ||
self.assertIn(">>>> I'm None/None@user/channel".format(self.lib1_ref), t.out) | ||
self.assertIn(">>>> content: {}".format(self.lib1_ref), t.out) | ||
finally: | ||
t.current_folder = old_wd | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_local_workflow_root_folder(self, use_scm_folder): | ||
with environment_append({'USE_SCM_FOLDER': use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner("svn co {}/lib1 .".format(self.url), cwd=t.current_folder) | ||
|
||
# Local workflow (from root folder) | ||
self._run_local_test(t, t.current_folder, ".") | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_local_workflow_root_folder_monorepo(self, use_scm_folder): | ||
with environment_append({'USE_SCM_FOLDER': use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner("svn co {} .".format(self.url), cwd=t.current_folder) | ||
|
||
# Local workflow (from root folder) | ||
self._run_local_test(t, t.current_folder, "lib1") | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_local_workflow_root_folder_monorepo_chdir(self, use_scm_folder): | ||
with environment_append({'USE_SCM_FOLDER': use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner("svn co {} .".format(self.url), cwd=t.current_folder) | ||
|
||
# Local workflow (from inner folder) | ||
self._run_local_test(t, os.path.join(t.current_folder, "lib1"), ".") | ||
|
||
def _run_remote_test(self, t, working_dir, path_to_conanfile): | ||
old_wd = t.current_folder | ||
try: | ||
t.current_folder = working_dir | ||
t.run("create {} {}".format(path_to_conanfile, self.lib1_ref)) | ||
self.assertIn(">>>> I'm {}".format(self.lib1_ref), t.out) | ||
self.assertIn(">>>> content: {}".format(self.lib1_ref), t.out) | ||
finally: | ||
t.current_folder = old_wd | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_remote_workflow(self, use_scm_folder): | ||
with environment_append({"USE_SCM_FOLER": use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner("svn co {}/lib1 .".format(self.url), cwd=t.current_folder) | ||
|
||
# Remote workflow | ||
self._run_remote_test(t, t.current_folder, ".") | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_remote_workflow_monorepo(self, use_scm_folder): | ||
with environment_append({"USE_SCM_FOLER": use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner("svn co {} .".format(self.url), cwd=t.current_folder) | ||
|
||
# Remote workflow | ||
self._run_remote_test(t, t.current_folder, "lib1") | ||
|
||
@parameterized.expand([("True",), ("False",)]) | ||
def test_remote_workflow_monorepo_chdir(self, use_scm_folder): | ||
with environment_append({"USE_SCM_FOLER": use_scm_folder}): | ||
t = TestClient(path_with_spaces=False) | ||
t.runner("svn co {} .".format(self.url), cwd=t.current_folder) | ||
|
||
# Remote workflow | ||
self._run_remote_test(t, os.path.join(t.current_folder, "lib1"), ".") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are here just to be able to run tests without the
scm_folder.txt
file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USE_SCM_FOLER => USE_SCM_FOLDER?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ ...at least it was copy/pasted everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is only for testing I don't like it, but we could consider this a feature naming in properly:
CONAN_USE_SCM_FOLDER
. To discuss.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it is only to make these tests possible. I want you all to review the tests, check the failing ones, they are showing some bugs that cannot be fixed without adding something else to the model.