Skip to content
Open
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
2 changes: 1 addition & 1 deletion pytests/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_install_package_verbose(utils):
def test_dummy_requires(utils):
pkg = utils.config["dummy_requires_pkgname"]
ret = utils.run(['tdnf', 'install', '-y', pkg])
assert ' nothing provides ' in ret['stderr'][0]
assert "nothing provides" in "\n".join(ret['stderr'])


def test_install_testonly(utils):
Expand Down
13 changes: 13 additions & 0 deletions pytests/tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,16 @@ def test_list_notinstalled(utils):
# spkg is not installed, expect error
ret = utils.run(['tdnf', 'list', cmd, spkg])
assert ret['retval'] == 1011


def test_list_invalid_with_valid(utils):
spkg = utils.config["sglversion_pkgname"]

ret = utils.run(f"tdnf list {spkg} invalid1")
assert ret['retval'] == 1011
assert "No match found for 'invalid1'" in ret['stderr']

ret = utils.run(f"tdnf list invalid1 {spkg} invalid2")
assert ret['retval'] == 1011
assert "No match found for 'invalid1'" in ret['stderr']
assert "No match found for 'invalid2'" in ret['stderr']
2 changes: 1 addition & 1 deletion pytests/tests/test_provides.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def test_provides_valid_pkg_name(utils):

def test_provides_invalid_pkg_name(utils):
ret = utils.run(['tdnf', 'provides', 'invalid_pkg_name'])
assert ret['stderr'][0] == 'No data available'
assert 'No data available' in ret['stderr']
20 changes: 18 additions & 2 deletions pytests/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,26 @@ def test_search_invalid_arg(utils):


def test_search_single(utils):
ret = utils.run(['tdnf', 'search', 'tdnf'])
pkgname = utils.config["sglversion_pkgname"]
ret = utils.run(['tdnf', 'search', pkgname])
assert ret['retval'] == 0


def test_search_multiple(utils):
ret = utils.run(['tdnf', 'search', 'tdnf', 'wget', 'gzip'])
sglpkgname = utils.config["sglversion_pkgname"]
mulpkgname = utils.config["mulversion_pkgname"]
ret = utils.run(['tdnf', 'search', sglpkgname, mulpkgname])
assert ret['retval'] == 0


def test_search_valid_with_invalid(utils):
sglpkgname = utils.config["sglversion_pkgname"]

ret = utils.run(f"tdnf search {sglpkgname} invalid1")
assert ret['retval'] == 1599
assert "No search results found for 'invalid1'" in ret['stderr']

ret = utils.run(f"tdnf search {sglpkgname} invalid1 invalid2")
assert ret['retval'] == 1599
assert "No search results found for 'invalid1'" in ret['stderr']
assert "No search results found for 'invalid2'" in ret['stderr']
2 changes: 1 addition & 1 deletion pytests/tests/test_whatprovides.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_whatprovides_no_arg(utils):
def test_whatprovides_invalid_arg(utils):
ret = utils.run(['tdnf', 'whatprovides', 'invalid_arg'])
assert ret['retval'] == 0
assert ret['stderr'][0] == 'No data available'
assert 'No data available' in ret['stderr']


def test_whatprovides_valid_file_notinstalled(utils):
Expand Down
22 changes: 22 additions & 0 deletions solv/tdnfquery.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ SolvGenerateCommonJob(
Queue queueJob = {0};
uint32_t nFlags = 0;
uint32_t nRetFlags = 0;
uint32_t retVal = 0;

if(!pQuery || !pQuery->pSack)
{
Expand Down Expand Up @@ -498,6 +499,12 @@ SolvGenerateCommonJob(
queueJob.count,
queueJob.elements);
}
else
{
pr_err("No match found for '%s'\n", *ppszPkgNames);
if (retVal == 0)
retVal = ERROR_TDNF_NO_MATCH;
}
ppszPkgNames++;
}
}
Expand All @@ -514,6 +521,9 @@ SolvGenerateCommonJob(

cleanup:
queue_free(&queueJob);
if (retVal)
dwError = retVal;

return dwError;

error:
Expand Down Expand Up @@ -713,6 +723,7 @@ SolvApplySearch(
Dataiterator di = {0};
Pool* pPool = NULL;
uint32_t dwError = 0;
uint32_t retVal = 0;
int nIndex = 0;
Queue queueSel = {0};
Queue queueResult = {0};
Expand All @@ -728,6 +739,8 @@ SolvApplySearch(

for(nIndex = dwStartIndex; nIndex < dwEndIndex; nIndex++)
{
int countBeforeInsert = 0;

queue_empty(&queueSel);
queue_empty(&queueResult);
dataiterator_init(&di, pPool, 0, 0, 0, ppszSearchStrings[nIndex],
Expand All @@ -747,15 +760,24 @@ SolvApplySearch(
dataiterator_free(&di);

selection_solvables(pPool, &queueSel, &queueResult);
countBeforeInsert = pQuery->queueResult.count;
queue_insertn(&pQuery->queueResult,
pQuery->queueResult.count,
queueResult.count,
queueResult.elements);

if (pQuery->queueResult.count == countBeforeInsert) {
pr_err("No search results found for '%s'\n", ppszSearchStrings[nIndex]);
if (retVal == 0)
retVal = ERROR_TDNF_NO_MATCH;
}
}

cleanup:
queue_free(&queueSel);
queue_free(&queueResult);
if (retVal)
dwError = retVal;
return dwError;

error:
Expand Down