Skip to content

Commit

Permalink
conan-io#6693 Check for description in JSON output
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed Mar 24, 2020
1 parent a981efe commit b4cc2fc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conans/client/command.py
Expand Up @@ -583,7 +583,7 @@ def info(self, *args):
"""

info_only_options = ["id", "build_id", "remote", "url", "license", "requires", "update",
"required", "date", "author", "None"]
"required", "date", "author", "description", "None"]
path_only_options = ["export_folder", "build_folder", "package_folder", "source_folder"]
str_path_only_options = ", ".join(['"%s"' % field for field in path_only_options])
str_only_options = ", ".join(['"%s"' % field for field in info_only_options])
Expand Down
1 change: 1 addition & 0 deletions conans/client/conan_command_output.py
Expand Up @@ -170,6 +170,7 @@ def _add_if_exists(attrib, as_list=False):
_add_if_exists("homepage")
_add_if_exists("license", as_list=True)
_add_if_exists("author")
_add_if_exists("description")
_add_if_exists("topics", as_list=True)

if isinstance(ref, ConanFileReference):
Expand Down
24 changes: 21 additions & 3 deletions conans/test/functional/command/info_test.py
Expand Up @@ -56,12 +56,14 @@ def _create(self, number, version, deps=None, deps_dev=None, export=True):
files[CONANFILE] = files[CONANFILE].replace('version = "0.1"',
'version = "0.1"\n'
' url= "myurl"\n'
' license = "MIT"')
' license = "MIT"\n'
' description = "blah"')
else:
files[CONANFILE] = files[CONANFILE].replace('version = "0.1"',
'version = "0.1"\n'
' url= "myurl"\n'
' license = "MIT", "GPL"')
' license = "MIT", "GPL"\n'
' description = "foobar"')

self.client.save(files)
if export:
Expand Down Expand Up @@ -293,7 +295,7 @@ def info_virtual_test(self):
self.assertNotIn("virtual", self.client.out)
self.assertNotIn("Required", self.client.out)

def reuse_test(self):
def test_reuse(self):
self.client = TestClient()
self._create("Hello0", "0.1")
self._create("Hello1", "0.1", ["Hello0/0.1@lasote/stable"])
Expand Down Expand Up @@ -377,6 +379,20 @@ def clean_output(output):

self.assertIn(expected_output, clean_output(self.client.out))

self.client.run("info . -u --only=url --only=license --only=description")
expected_output = textwrap.dedent(
"""\
Hello0/0.1@lasote/stable
URL: myurl
License: MIT
Hello1/0.1@lasote/stable
URL: myurl
License: MIT
conanfile.py (Hello2/0.1)
URL: myurl
Licenses: MIT, GPL""")
self.assertIn(expected_output, clean_output(self.client.out))

def test_json_info_outputs(self):
self.client = TestClient()
self._create("LibA", "0.1")
Expand All @@ -396,8 +412,10 @@ def test_json_info_outputs(self):
content = json.loads(load(json_file))
self.assertEqual(content[0]["reference"], "LibA/0.1@lasote/stable")
self.assertEqual(content[0]["license"][0], "MIT")
self.assertEqual(content[0]["description"], "blah")
self.assertEqual(content[1]["url"], "myurl")
self.assertEqual(content[1]["required_by"][0], "conanfile.py (LibD/0.1)")
self.assertEqual(content[1]["required_by"][0], "conanfile.py (LibD/0.1)")

def build_order_test(self):
self.client = TestClient()
Expand Down

0 comments on commit b4cc2fc

Please sign in to comment.