Skip to content
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

Make initial solvable finding more accurate #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
12 changes: 9 additions & 3 deletions fus.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,15 @@ add_solvable_to_pile (const char *solvable,
{
g_auto(Queue) sel;
queue_init (&sel);
/* First let's select packages based on name, glob or name.arch combination ... */
selection_make (pool, &sel, solvable,
SELECTION_NAME | SELECTION_PROVIDES | SELECTION_GLOB | SELECTION_DOTARCH);
/* First let's select packages based on name, glob or name.arch combination,
* and select modules based only on Provides: module(...). We don't want to
* pull it non-modular packages that only Provide the requested name ... */
int flags;
if (g_str_has_prefix (solvable, "module("))
flags = SELECTION_PROVIDES;
else
flags = SELECTION_NAME | SELECTION_GLOB | SELECTION_DOTARCH;
selection_make (pool, &sel, solvable, flags);
/* ... then remove masked packages from the selection (either hidden in
* non-default module stream) or bare RPMs hidden by a package in default
* module stream) ... */
Expand Down
39 changes: 39 additions & 0 deletions tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#define ADD_SOLV_FAIL_TEST(name, dir) \
g_test_add(name, TestData, dir, test_setup, test_broken_dep, test_teardown)

#define ADD_SOLV_NO_SOLVABLES_TEST(name, dir) \
g_test_add(name, TestData, dir, test_setup, test_no_solvables, test_teardown)

typedef struct _test_data {
GPtrArray *repos;
GStrv solvables;
Expand Down Expand Up @@ -58,6 +61,40 @@ test_broken_dep (TestData *td, gconstpointer data)
}
}

static void
test_no_solvables (TestData *td, gconstpointer data)
{
GStrv repos = (char **)td->repos->pdata;
const gchar *dir = data;

if (g_test_subprocess ())
{
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) result = NULL;
//g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR,
// "*No solvables matched*");
result = fus_depsolve (ARCH, PLATFORM, NULL, repos, td->solvables, &error);
g_assert_null (result);
g_assert_nonnull (error);
g_assert_error (error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED);
return;
}

g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_passed ();

const char *probfile = g_test_get_filename (G_TEST_DIST, dir, "problems", NULL);
if (g_file_test (probfile, G_FILE_TEST_IS_REGULAR))
{
g_autofree char *content = NULL;
g_autoptr(GError) error = NULL;
g_file_get_contents (probfile, &content, NULL, &error);
g_assert_no_error (error);
g_assert (content != NULL);
g_test_trap_assert_stderr (content);
}
}

static void
test_fail_invalid_solvable (void)
{
Expand Down Expand Up @@ -287,5 +324,7 @@ int main (int argc, char **argv)

ADD_TEST ("/modulemd-packager-v3/static-context", "static-context");

ADD_SOLV_NO_SOLVABLES_TEST ("/fail/ursine/only-provides-name", "only-provides-name");

return g_test_run ();
}
Empty file.
1 change: 1 addition & 0 deletions tests/only-provides-name/input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
4 changes: 4 additions & 0 deletions tests/only-provides-name/packages.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=Ver: 2.0

=Pkg: foobar 3:0.1.7 7 x86_64
=Prv: foo = 3:0.1.7-7
1 change: 1 addition & 0 deletions tests/only-provides-name/problems
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*Nothing matches 'foo'*