summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-02-23 22:02:11 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-02-23 22:05:02 +0200
commit64e5a64442194a73e75ef11039f7d1e18d60c15e (patch)
treeab8f11613158d54302cc04bcab99cc4af3036af4
parent082ffbd3d6e713ba8c24b428c46af30c799aac6b (diff)
downloadapk-tools-64e5a64442194a73e75ef11039f7d1e18d60c15e.tar.gz
apk-tools-64e5a64442194a73e75ef11039f7d1e18d60c15e.tar.bz2
apk-tools-64e5a64442194a73e75ef11039f7d1e18d60c15e.tar.xz
apk-tools-64e5a64442194a73e75ef11039f7d1e18d60c15e.zip
test: rewrite the testing framework to use the real applets
also merge the expected output to the *.test files.
-rw-r--r--.gitignore2
-rw-r--r--src/Makefile9
l---------src/apk-test.c1
-rw-r--r--src/apk.c63
-rw-r--r--src/test.c227
-rw-r--r--test/basic1.expect2
-rw-r--r--test/basic1.test9
-rw-r--r--test/basic2.expect0
-rw-r--r--test/basic2.test9
-rw-r--r--test/basic3.expect2
-rw-r--r--test/basic3.test11
-rw-r--r--test/basic4.expect1
-rw-r--r--test/basic4.test10
-rw-r--r--test/basic5.expect2
-rw-r--r--test/basic5.test11
-rw-r--r--test/basic6.expect0
-rw-r--r--test/basic6.test9
-rw-r--r--test/basic7.expect0
-rw-r--r--test/basic7.test10
-rw-r--r--test/complicated1.expect4
-rw-r--r--test/complicated1.test11
-rw-r--r--test/complicated2.expect3
-rw-r--r--test/complicated2.test10
-rw-r--r--test/complicated3.expect2
-rw-r--r--test/complicated3.test9
-rw-r--r--test/complicated4.expect4
-rw-r--r--test/complicated4.test13
-rw-r--r--test/conflict.repo2
-rw-r--r--test/conflict1.expect2
-rw-r--r--test/conflict1.test7
-rw-r--r--test/conflict2.expect2
-rw-r--r--test/conflict2.test6
-rw-r--r--test/error1.expect2
-rw-r--r--test/error1.test8
-rw-r--r--test/error2.expect2
-rw-r--r--test/error2.test8
-rw-r--r--test/error3.expect2
-rw-r--r--test/error3.test8
-rw-r--r--test/error4.expect2
-rw-r--r--test/error4.test8
-rw-r--r--test/error5.expect2
-rw-r--r--test/error5.test8
-rw-r--r--test/installif1.expect4
-rw-r--r--test/installif1.test11
-rw-r--r--test/installif2.expect6
-rw-r--r--test/installif2.test13
-rw-r--r--test/installif3.expect4
-rw-r--r--test/installif3.test12
-rw-r--r--test/pinning1.expect2
-rw-r--r--test/pinning1.test10
-rw-r--r--test/pinning2.expect2
-rw-r--r--test/pinning2.test10
-rw-r--r--test/pinning3.expect2
-rw-r--r--test/pinning3.test10
-rw-r--r--test/pinning4.expect3
-rw-r--r--test/pinning4.test11
-rwxr-xr-xtest/solver.sh22
57 files changed, 279 insertions, 346 deletions
diff --git a/.gitignore b/.gitignore
index 8ef0e46..5e393a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
src/apk
-src/apk_test
+src/apk-test
src/apk.static
test/*.got
*.o
diff --git a/src/Makefile b/src/Makefile
index 11aa305..9ec554f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -27,16 +27,18 @@ libapk.so-objs := common.o database.o package.o archive.o \
solver.o
ifeq ($(TEST),y)
-progs-y += apk_test
-apk_test-objs := apk.o test.o $(libapk.so-objs)
+progs-y += apk-test
+apk-test-objs := apk-test.o $(filter-out apk.o, $(apk-objs))
endif
ifeq ($(SHARED_LIBAPK),)
apk-objs += $(libapk.so-objs)
+apk-test-objs += $(libapk.so-objs)
apk.so-objs += $(libapk.so-objs)
else
LIBAPK := YesPlease
LIBS_apk := -lapk
+LIBS_apk-test := -lapk
LIBS_apk.so := -L$(obj) -lapk
endif
@@ -50,12 +52,13 @@ endif
CFLAGS_ALL += -D_ATFILE_SOURCE
CFLAGS_apk.o := -DAPK_VERSION=\"$(FULL_VERSION)\"
CFLAGS_apk-static.o := -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE
+CFLAGS_apk-test.o := -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE -DTEST_MODE
progs-$(STATIC) += apk.static
apk.static-objs := $(filter-out apk.o,$(apk-objs)) apk-static.o
LDFLAGS_apk.static := -static
LDFLAGS_apk += -nopie -L$(obj)
-LDFLAGS_apk_test += -nopie -L$(obj)
+LDFLAGS_apk-test += -nopie -L$(obj)
CFLAGS_ALL += $(shell $(PKG_CONFIG) --cflags $(PKGDEPS))
LIBS := -Wl,--as-needed \
diff --git a/src/apk-test.c b/src/apk-test.c
new file mode 120000
index 0000000..bf745af
--- /dev/null
+++ b/src/apk-test.c
@@ -0,0 +1 @@
+apk.c \ No newline at end of file
diff --git a/src/apk.c b/src/apk.c
index 8fb0924..254a932 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -31,6 +31,7 @@
#include "apk_applet.h"
#include "apk_blob.h"
#include "apk_print.h"
+#include "apk_io.h"
char **apk_argv;
@@ -67,11 +68,19 @@ static struct apk_option generic_options[] = {
{ 0x111, "overlay-from-stdin", "Read list of overlay files from stdin" },
{ 0x112, "arch", "Use architecture with --root",
required_argument, "ARCH" },
+#ifdef TEST_MODE
+ { 0x200, "test-repo", "Repository", required_argument, "REPO" },
+ { 0x201, "test-instdb", "Installed db", required_argument, "INSTALLED" },
+ { 0x202, "test-world", "World", required_argument, "WORLD DEPS" },
+#endif
};
static int version(void)
{
printf("apk-tools " APK_VERSION ", compiled for " APK_DEFAULT_ARCH ".\n");
+#ifdef TEST_MODE
+ printf("TEST MODE BUILD. NOT FOR PRODUCTION USE.\n");
+#endif
return 0;
}
@@ -273,6 +282,14 @@ int main(int argc, char **argv)
struct apk_repository_list *repo = NULL;
struct apk_database db;
struct apk_db_options dbopts;
+#ifdef TEST_MODE
+ const char *test_installed_db = NULL;
+ const char *test_world = NULL;
+ struct apk_string_array *test_repos;
+ int i;
+
+ apk_string_array_init(&test_repos);
+#endif
apk_argv = malloc(sizeof(char*[argc+2]));
memcpy(apk_argv, argv, sizeof(char*[argc]));
@@ -383,6 +400,17 @@ int main(int argc, char **argv)
case 0x112:
dbopts.arch = optarg;
break;
+#ifdef TEST_MODE
+ case 0x200:
+ *apk_string_array_add(&test_repos) = (char*) optarg;
+ break;
+ case 0x201:
+ test_installed_db = optarg;
+ break;
+ case 0x202:
+ test_world = optarg;
+ break;
+#endif
default:
if (applet == NULL || applet->parse == NULL ||
applet->parse(ctx, &dbopts, r,
@@ -407,6 +435,12 @@ int main(int argc, char **argv)
argv++;
}
+#ifdef TEST_MODE
+ dbopts.open_flags &= ~(APK_OPENF_WRITE | APK_OPENF_CACHE_WRITE | APK_OPENF_CREATE);
+ dbopts.open_flags |= APK_OPENF_READ | APK_OPENF_NO_STATE | APK_OPENF_NO_REPOS;
+ apk_flags |= APK_SIMULATE;
+ apk_flags &= ~APK_INTERACTIVE;
+#endif
r = apk_db_open(&db, &dbopts);
if (r != 0) {
apk_error("Failed to open apk database: %s",
@@ -414,6 +448,35 @@ int main(int argc, char **argv)
goto err;
}
+#ifdef TEST_MODE
+ if (test_world != NULL) {
+ apk_blob_t b = APK_BLOB_STR(test_world);
+ apk_blob_pull_deps(&b, &db, &db.world);
+ }
+ if (test_installed_db != NULL) {
+ struct apk_bstream *bs = apk_bstream_from_file(AT_FDCWD, test_installed_db);
+ if (bs != NULL) {
+ apk_db_index_read(&db, bs, -1);
+ bs->close(bs, NULL);
+ }
+ }
+ for (i = 0; i < test_repos->num; i++) {
+ struct apk_bstream *bs;
+ char *fn = test_repos->item[i];
+ int repo_tag = 0;
+ if (fn[0] == '+') {
+ repo_tag = apk_db_get_tag_id(&db, APK_BLOB_STR("testing"));
+ fn++;
+ }
+ bs = apk_bstream_from_file(AT_FDCWD, fn);
+ if (bs != NULL) {
+ apk_db_index_read(&db, bs, i);
+ db.repo_tags[repo_tag].allowed_repos |= BIT(i);
+ bs->close(bs, NULL);
+ }
+ }
+#endif
+
r = applet->main(ctx, &db, argc, argv);
apk_db_close(&db);
diff --git a/src/test.c b/src/test.c
deleted file mode 100644
index 8f34429..0000000
--- a/src/test.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* test.c - Alpine Package Keeper (APK)
- *
- * Copyright (C) 2008-2011 Timo Teräs <timo.teras@iki.fi>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation. See http://www.gnu.org/ for details.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include "apk_applet.h"
-#include "apk_database.h"
-#include "apk_solver.h"
-#include "apk_io.h"
-#include "apk_print.h"
-
-struct test_ctx {
- const char *installed_db;
- struct apk_string_array *repos;
- unsigned short solver_flags;
-};
-
-static int test_parse(void *pctx, struct apk_db_options *dbopts,
- int optch, int optindex, const char *optarg)
-{
- struct test_ctx *ctx = (struct test_ctx *) pctx;
-
- switch (optch) {
- case 0x10000:
- ctx->installed_db = optarg;
- break;
- case 0x10001:
- if (ctx->repos == NULL)
- apk_string_array_init(&ctx->repos);
- *apk_string_array_add(&ctx->repos) = (char*) optarg;
- break;
- case 'u':
- ctx->solver_flags |= APK_SOLVERF_UPGRADE;
- break;
- case 'a':
- ctx->solver_flags |= APK_SOLVERF_AVAILABLE;
- break;
- default:
- return -1;
- }
- return 0;
-}
-
-static inline void print_change(struct apk_package *oldpkg,
- struct apk_package *newpkg)
-{
- const char *msg = NULL;
- struct apk_name *name;
- int r;
-
- if (oldpkg != NULL)
- name = oldpkg->name;
- else
- name = newpkg->name;
-
- if (oldpkg == NULL) {
- apk_message("Installing %s (" BLOB_FMT ")",
- name->name,
- BLOB_PRINTF(*newpkg->version));
- } else if (newpkg == NULL) {
- apk_message("Purging %s (" BLOB_FMT ")",
- name->name,
- BLOB_PRINTF(*oldpkg->version));
- } else {
- r = apk_pkg_version_compare(newpkg, oldpkg);
- switch (r) {
- case APK_VERSION_LESS:
- msg = "Downgrading";
- break;
- case APK_VERSION_EQUAL:
- if (newpkg == oldpkg)
- msg = "Re-installing";
- else
- msg = "Replacing";
- break;
- case APK_VERSION_GREATER:
- msg = "Upgrading";
- break;
- }
- apk_message("%s %s (" BLOB_FMT " -> " BLOB_FMT ")",
- msg, name->name,
- BLOB_PRINTF(*oldpkg->version),
- BLOB_PRINTF(*newpkg->version));
- }
-}
-
-static void print_dep_errors(struct apk_database *db, char *label, struct apk_dependency_array *deps)
-{
- int i, print_label = 1;
- char buf[256];
- apk_blob_t p = APK_BLOB_BUF(buf);
-
- for (i = 0; i < deps->num; i++) {
- struct apk_dependency *dep = &deps->item[i];
- struct apk_package *pkg = dep->name->state_ptr;
-
- if (apk_dep_is_satisfied(dep, pkg))
- continue;
-
- if (print_label) {
- print_label = 0;
- printf("%s: ", label);
- } else {
- printf(" ");
- }
- apk_blob_push_dep(&p, db, dep);
- p = apk_blob_pushed(APK_BLOB_BUF(buf), p);
- fwrite(p.ptr, p.len, 1, stdout);
- }
- if (!print_label)
- printf("\n");
-}
-
-static void print_errors_in_solution(struct apk_database *db, int unsatisfiable,
- struct apk_solution_array *solution)
-{
- int i;
-
- printf("%d unsatisfiable dependencies (solution with %zu names)\n",
- unsatisfiable, solution->num);
-
- for (i = 0; i < solution->num; i++) {
- struct apk_package *pkg = solution->item[i].pkg;
- pkg->name->state_ptr = pkg;
- }
-
- print_dep_errors(db, "world", db->world);
- for (i = 0; i < solution->num; i++) {
- struct apk_package *pkg = solution->item[i].pkg;
- char pkgtext[256];
- snprintf(pkgtext, sizeof(pkgtext), PKG_VER_FMT, PKG_VER_PRINTF(pkg));
- print_dep_errors(db, pkgtext, pkg->depends);
- }
-
-}
-
-static int test_main(void *pctx, struct apk_database *db, int argc, char **argv)
-{
- struct test_ctx *ctx = (struct test_ctx *) pctx;
- struct apk_bstream *bs;
- struct apk_solution_array *solution = NULL;
- struct apk_changeset changeset = {};
- apk_blob_t b;
- int i, r;
-
- if (argc != 1)
- return -EINVAL;
-
- apk_db_get_tag_id(db, APK_BLOB_STR("testing"));
-
- /* load installed db */
- if (ctx->installed_db != NULL) {
- bs = apk_bstream_from_file(AT_FDCWD, ctx->installed_db);
- if (bs != NULL) {
- apk_db_index_read(db, bs, -1);
- bs->close(bs, NULL);
- }
- }
-
- /* load additional indexes */
- if (ctx->repos) {
- for (i = 0; i < ctx->repos->num; i++) {
- char *fn = ctx->repos->item[i];
- int repo = 0;
- if (fn[0] == '+') {
- fn++;
- repo = 1;
- }
- bs = apk_bstream_from_file(AT_FDCWD, fn);
- if (bs != NULL) {
- apk_db_index_read(db, bs, i);
- db->repo_tags[repo].allowed_repos |= BIT(i);
- bs->close(bs, NULL);
- }
- }
- }
-
- /* construct new world */
- b = APK_BLOB_STR(argv[0]);
- apk_blob_pull_deps(&b, db, &db->world);
-
- /* run solver */
- r = apk_solver_solve(db, ctx->solver_flags, db->world, &solution, &changeset);
- if (r == 0) {
- /* dump changeset */
- for (i = 0; i < changeset.changes->num; i++) {
- struct apk_change *c = &changeset.changes->item[i];
- print_change(c->oldpkg, c->newpkg);
- }
- } else { /* r >= 1*/
- print_errors_in_solution(db, r, solution);
- }
-
- return 0;
-}
-
-static struct apk_option test_options[] = {
- { 0x10000, "installed", "Installed database",
- required_argument, "DB" },
- { 0x10001, "raw-repository", "Add unsigned test repository index",
- required_argument, "INDEX" },
- { 'u', "upgrade", "Prefer to upgrade package" },
- { 'a', "available",
- "Re-install or downgrade if currently installed package is not "
- "currently available from any repository" },
-};
-
-static struct apk_applet test_applet = {
- .name = "test",
- .help = "Test dependency graph solver (uses simple repository and installed db)",
- .arguments = "'WORLD'",
- .open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE | APK_OPENF_NO_REPOS,
- .context_size = sizeof(struct test_ctx),
- .num_options = ARRAY_SIZE(test_options),
- .options = test_options,
- .parse = test_parse,
- .main = test_main,
-};
-
-APK_DEFINE_APPLET(test_applet);
diff --git a/test/basic1.expect b/test/basic1.expect
deleted file mode 100644
index 81756fe..0000000
--- a/test/basic1.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Installing b (2)
-Installing a (2)
diff --git a/test/basic1.test b/test/basic1.test
index b3a4bb7..b906cc4 100644
--- a/test/basic1.test
+++ b/test/basic1.test
@@ -1,2 +1,7 @@
---raw-repository basic.repo
-a
+@ARGS
+--test-repo basic.repo
+add a
+@EXPECT
+(1/2) Installing b (2)
+(2/2) Installing a (2)
+OK: 0 MiB in 0 packages
diff --git a/test/basic2.expect b/test/basic2.expect
deleted file mode 100644
index e69de29..0000000
--- a/test/basic2.expect
+++ /dev/null
diff --git a/test/basic2.test b/test/basic2.test
index 75b172c..e89d0dd 100644
--- a/test/basic2.test
+++ b/test/basic2.test
@@ -1,2 +1,7 @@
---raw-repository basic.repo --installed basic.installed
-a
+@ARGS
+--test-repo basic.repo
+--test-instdb basic.installed
+--test-world a
+add
+@EXPECT
+OK: 0 MiB in 2 packages
diff --git a/test/basic3.expect b/test/basic3.expect
deleted file mode 100644
index 73bef16..0000000
--- a/test/basic3.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Upgrading b (1 -> 2)
-Upgrading a (1 -> 2)
diff --git a/test/basic3.test b/test/basic3.test
index 0a790a4..9efee6b 100644
--- a/test/basic3.test
+++ b/test/basic3.test
@@ -1,2 +1,9 @@
---raw-repository basic.repo --installed basic.installed -u
-a
+@ARGS
+--test-repo basic.repo
+--test-instdb basic.installed
+--test-world a
+upgrade
+@EXPECT
+(1/2) Upgrading b (1 -> 2)
+(2/2) Upgrading a (1 -> 2)
+OK: 0 MiB in 2 packages
diff --git a/test/basic4.expect b/test/basic4.expect
deleted file mode 100644
index 9dacff1..0000000
--- a/test/basic4.expect
+++ /dev/null
@@ -1 +0,0 @@
-Purging a (1)
diff --git a/test/basic4.test b/test/basic4.test
index b12d9cf..906c1e9 100644
--- a/test/basic4.test
+++ b/test/basic4.test
@@ -1,2 +1,8 @@
---raw-repository basic.repo --installed basic.installed
-b
+@ARGS
+--test-repo basic.repo
+--test-instdb basic.installed
+--test-world "a b"
+del a
+@EXPECT
+(1/1) Purging a (1)
+OK: 0 MiB in 2 packages
diff --git a/test/basic5.expect b/test/basic5.expect
deleted file mode 100644
index b29db17..0000000
--- a/test/basic5.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Replacing b (2 -> 2)
-Replacing a (2 -> 2)
diff --git a/test/basic5.test b/test/basic5.test
index 40bf72a..854f5e7 100644
--- a/test/basic5.test
+++ b/test/basic5.test
@@ -1,2 +1,9 @@
---raw-repository basic.repo --installed basic.installed2 -a
-a
+@ARGS
+--test-repo basic.repo
+--test-instdb basic.installed2
+--test-world a
+upgrade -a
+@EXPECT
+(1/2) Replacing b (2 -> 2)
+(2/2) Replacing a (2 -> 2)
+OK: 0 MiB in 2 packages
diff --git a/test/basic6.expect b/test/basic6.expect
deleted file mode 100644
index e69de29..0000000
--- a/test/basic6.expect
+++ /dev/null
diff --git a/test/basic6.test b/test/basic6.test
index d9fbe64..6914767 100644
--- a/test/basic6.test
+++ b/test/basic6.test
@@ -1,2 +1,7 @@
---raw-repository basic.repo --installed basic.installed2
-a
+@ARGS
+--test-repo basic.repo
+--test-instdb basic.installed2
+--test-world a
+upgrade
+@EXPECT
+OK: 0 MiB in 2 packages
diff --git a/test/basic7.expect b/test/basic7.expect
deleted file mode 100644
index e69de29..0000000
--- a/test/basic7.expect
+++ /dev/null
diff --git a/test/basic7.test b/test/basic7.test
index c53d2d2..a1f153a 100644
--- a/test/basic7.test
+++ b/test/basic7.test
@@ -1,2 +1,8 @@
---no-network --raw-repository basic.repo --installed basic.installed -u
-a
+@ARGS
+--no-network
+--test-repo basic.repo
+--test-instdb basic.installed
+--test-world a
+upgrade
+@EXPECT
+OK: 0 MiB in 2 packages
diff --git a/test/complicated1.expect b/test/complicated1.expect
deleted file mode 100644
index 1387f53..0000000
--- a/test/complicated1.expect
+++ /dev/null
@@ -1,4 +0,0 @@
-Installing d (1.5)
-Installing c (1)
-Installing b (1)
-Installing a (2)
diff --git a/test/complicated1.test b/test/complicated1.test
index 070f2e1..53ea08a 100644
--- a/test/complicated1.test
+++ b/test/complicated1.test
@@ -1,2 +1,9 @@
---raw-repository complicated1.repo
-a
+@ARGS
+--test-repo complicated1.repo
+add a
+@EXPECT
+(1/4) Installing d (1.5)
+(2/4) Installing c (1)
+(3/4) Installing b (1)
+(4/4) Installing a (2)
+OK: 0 MiB in 0 packages
diff --git a/test/complicated2.expect b/test/complicated2.expect
deleted file mode 100644
index 5261d10..0000000
--- a/test/complicated2.expect
+++ /dev/null
@@ -1,3 +0,0 @@
-Installing d (1.5)
-Installing c (1)
-Installing b (1)
diff --git a/test/complicated2.test b/test/complicated2.test
index e2d0ef3..bdcf9e5 100644
--- a/test/complicated2.test
+++ b/test/complicated2.test
@@ -1,2 +1,8 @@
---raw-repository complicated1.repo
-b
+@ARGS
+--test-repo complicated1.repo
+add b
+@EXPECT
+(1/3) Installing d (1.5)
+(2/3) Installing c (1)
+(3/3) Installing b (1)
+OK: 0 MiB in 0 packages
diff --git a/test/complicated3.expect b/test/complicated3.expect
deleted file mode 100644
index e9b2733..0000000
--- a/test/complicated3.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Installing d (2.0)
-Installing c (1)
diff --git a/test/complicated3.test b/test/complicated3.test
index 2ddba5b..40bd7ea 100644
--- a/test/complicated3.test
+++ b/test/complicated3.test
@@ -1,2 +1,7 @@
---raw-repository complicated1.repo
-c
+@ARGS
+--test-repo complicated1.repo
+add c
+@EXPECT
+(1/2) Installing d (2.0)
+(2/2) Installing c (1)
+OK: 0 MiB in 0 packages
diff --git a/test/complicated4.expect b/test/complicated4.expect
deleted file mode 100644
index 44964e3..0000000
--- a/test/complicated4.expect
+++ /dev/null
@@ -1,4 +0,0 @@
-Upgrading d (1.0 -> 1.5)
-Installing c (1)
-Installing b (1)
-Installing a (2)
diff --git a/test/complicated4.test b/test/complicated4.test
index dafeaad..96e9e4a 100644
--- a/test/complicated4.test
+++ b/test/complicated4.test
@@ -1,2 +1,11 @@
---raw-repository complicated1.repo --installed complicated1.installed
-a
+@ARGS
+--test-repo complicated1.repo
+--test-instdb complicated1.installed
+--test-world d
+add a
+@EXPECT
+(1/4) Upgrading d (1.0 -> 1.5)
+(2/4) Installing c (1)
+(3/4) Installing b (1)
+(4/4) Installing a (2)
+OK: 0 MiB in 1 packages
diff --git a/test/conflict.repo b/test/conflict.repo
index a95658c..b49c115 100644
--- a/test/conflict.repo
+++ b/test/conflict.repo
@@ -3,7 +3,7 @@ P:a
V:1
S:1
I:1
-D:!b<2
+D:!b>1
C:Q1C4uoV7SdMdDhYg4OCVmI71D8HIA=
P:b
diff --git a/test/conflict1.expect b/test/conflict1.expect
deleted file mode 100644
index 03c6d67..0000000
--- a/test/conflict1.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Installing b (2)
-Installing a (1)
diff --git a/test/conflict1.test b/test/conflict1.test
new file mode 100644
index 0000000..c6403e3
--- /dev/null
+++ b/test/conflict1.test
@@ -0,0 +1,7 @@
+@ARGS
+--test-repo conflict.repo
+add a b
+@EXPECT
+(1/2) Installing b (1)
+(2/2) Installing a (1)
+OK: 0 MiB in 0 packages
diff --git a/test/conflict2.expect b/test/conflict2.expect
deleted file mode 100644
index 250f942..0000000
--- a/test/conflict2.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-1 unsatisfiable dependencies (solution with 2 names)
-world: b<2
diff --git a/test/conflict2.test b/test/conflict2.test
new file mode 100644
index 0000000..8235e9c
--- /dev/null
+++ b/test/conflict2.test
@@ -0,0 +1,6 @@
+@ARGS
+--test-repo conflict.repo
+add a b>1
+@EXPECT
+ERROR: 1 unsatisfiable dependencies:
+ a-1: !b>1
diff --git a/test/error1.expect b/test/error1.expect
deleted file mode 100644
index ddd4f4f..0000000
--- a/test/error1.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-1 unsatisfiable dependencies (solution with 4 names)
-b-1: d<2.0
diff --git a/test/error1.test b/test/error1.test
index 7925b24..3a165f5 100644
--- a/test/error1.test
+++ b/test/error1.test
@@ -1,2 +1,6 @@
---raw-repository complicated1.repo
-a d>1.5
+@ARGS
+--test-repo complicated1.repo
+add a d>1.5
+@EXPECT
+ERROR: 1 unsatisfiable dependencies:
+ b-1: d<2.0
diff --git a/test/error2.expect b/test/error2.expect
deleted file mode 100644
index 7faac5e..0000000
--- a/test/error2.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-1 unsatisfiable dependencies (solution with 4 names)
-world: d<1.5
diff --git a/test/error2.test b/test/error2.test
index c0b344a..506bcf2 100644
--- a/test/error2.test
+++ b/test/error2.test
@@ -1,2 +1,6 @@
---raw-repository complicated1.repo
-a d<1.5
+@ARGS
+--test-repo complicated1.repo
+add a d<1.5
+@EXPECT
+ERROR: 1 unsatisfiable dependencies:
+ world: d<1.5
diff --git a/test/error3.expect b/test/error3.expect
deleted file mode 100644
index d04f76e..0000000
--- a/test/error3.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-1 unsatisfiable dependencies (solution with 3 names)
-a-3: b
diff --git a/test/error3.test b/test/error3.test
index 0d5f97a..74a8176 100644
--- a/test/error3.test
+++ b/test/error3.test
@@ -1,2 +1,6 @@
---raw-repository complicated1.repo
-a !b
+@ARGS
+--test-repo complicated1.repo
+add a !b
+@EXPECT
+ERROR: 1 unsatisfiable dependencies:
+ a-3: b
diff --git a/test/error4.expect b/test/error4.expect
deleted file mode 100644
index a422aaa..0000000
--- a/test/error4.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-1 unsatisfiable dependencies (solution with 4 names)
-world: nonexistant
diff --git a/test/error4.test b/test/error4.test
index b26d13f..c05aa93 100644
--- a/test/error4.test
+++ b/test/error4.test
@@ -1,2 +1,6 @@
---raw-repository complicated1.repo
-a nonexistant
+@ARGS
+--test-repo complicated1.repo
+add a nonexistant
+@EXPECT
+ERROR: 1 unsatisfiable dependencies:
+ world: nonexistant
diff --git a/test/error5.expect b/test/error5.expect
deleted file mode 100644
index ddd4f4f..0000000
--- a/test/error5.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-1 unsatisfiable dependencies (solution with 4 names)
-b-1: d<2.0
diff --git a/test/error5.test b/test/error5.test
index 6c9371e..3086b20 100644
--- a/test/error5.test
+++ b/test/error5.test
@@ -1,2 +1,6 @@
---raw-repository complicated1.repo
-a>2
+@ARGS
+--test-repo complicated1.repo
+add a>2
+@EXPECT
+ERROR: 1 unsatisfiable dependencies:
+ b-1: d<2.0
diff --git a/test/installif1.expect b/test/installif1.expect
deleted file mode 100644
index d9ee058..0000000
--- a/test/installif1.expect
+++ /dev/null
@@ -1,4 +0,0 @@
-Installing foo (1)
-Installing lib (1)
-Installing app (1)
-Installing appiif1 (1)
diff --git a/test/installif1.test b/test/installif1.test
index 99e139a..ca3aeeb 100644
--- a/test/installif1.test
+++ b/test/installif1.test
@@ -1,2 +1,9 @@
---raw-repository installif1.repo
-foo app
+@ARGS
+--test-repo installif1.repo
+add foo app
+@EXPECT
+(1/4) Installing foo (1)
+(2/4) Installing lib (1)
+(3/4) Installing app (1)
+(4/4) Installing appiif1 (1)
+OK: 0 MiB in 0 packages
diff --git a/test/installif2.expect b/test/installif2.expect
deleted file mode 100644
index 0cd5d31..0000000
--- a/test/installif2.expect
+++ /dev/null
@@ -1,6 +0,0 @@
-Installing foo (1)
-Installing lib (1)
-Installing app (1)
-Installing appiif1 (1)
-Installing bar (1)
-Installing appiif2 (1)
diff --git a/test/installif2.test b/test/installif2.test
index f4f68f5..85f66dc 100644
--- a/test/installif2.test
+++ b/test/installif2.test
@@ -1,2 +1,11 @@
---raw-repository installif1.repo
-foo app bar
+@ARGS
+--test-repo installif1.repo
+add foo app bar
+@EXPECT
+(1/6) Installing foo (1)
+(2/6) Installing lib (1)
+(3/6) Installing app (1)
+(4/6) Installing appiif1 (1)
+(5/6) Installing bar (1)
+(6/6) Installing appiif2 (1)
+OK: 0 MiB in 0 packages
diff --git a/test/installif3.expect b/test/installif3.expect
deleted file mode 100644
index d9ee058..0000000
--- a/test/installif3.expect
+++ /dev/null
@@ -1,4 +0,0 @@
-Installing foo (1)
-Installing lib (1)
-Installing app (1)
-Installing appiif1 (1)
diff --git a/test/installif3.test b/test/installif3.test
index 881b664..f5ac259 100644
--- a/test/installif3.test
+++ b/test/installif3.test
@@ -1,2 +1,10 @@
---raw-repository installif1.repo --raw-repository installif2.repo
-foo app
+@ARGS
+--test-repo installif1.repo
+--test-repo installif2.repo
+add foo app
+@EXPECT
+(1/4) Installing foo (1)
+(2/4) Installing lib (1)
+(3/4) Installing app (1)
+(4/4) Installing appiif1 (1)
+OK: 0 MiB in 0 packages
diff --git a/test/pinning1.expect b/test/pinning1.expect
deleted file mode 100644
index 81756fe..0000000
--- a/test/pinning1.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Installing b (2)
-Installing a (2)
diff --git a/test/pinning1.test b/test/pinning1.test
index 4396875..311fa3f 100644
--- a/test/pinning1.test
+++ b/test/pinning1.test
@@ -1,2 +1,8 @@
---raw-repository basic.repo --raw-repository +pinning.repo
-a
+@ARGS
+--test-repo basic.repo
+--test-repo +pinning.repo
+add a
+@EXPECT
+(1/2) Installing b (2)
+(2/2) Installing a (2)
+OK: 0 MiB in 0 packages
diff --git a/test/pinning2.expect b/test/pinning2.expect
deleted file mode 100644
index cce6084..0000000
--- a/test/pinning2.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Installing b (2)
-Installing a (3)
diff --git a/test/pinning2.test b/test/pinning2.test
index 69d4f79..c655143 100644
--- a/test/pinning2.test
+++ b/test/pinning2.test
@@ -1,2 +1,8 @@
---raw-repository basic.repo --raw-repository +pinning.repo
-a@testing
+@ARGS
+--test-repo basic.repo
+--test-repo +pinning.repo
+add a@testing
+@EXPECT
+(1/2) Installing b (2)
+(2/2) Installing a@testing (3)
+OK: 0 MiB in 0 packages
diff --git a/test/pinning3.expect b/test/pinning3.expect
deleted file mode 100644
index a2b2fca..0000000
--- a/test/pinning3.expect
+++ /dev/null
@@ -1,2 +0,0 @@
-Installing b (3)
-Installing a (3)
diff --git a/test/pinning3.test b/test/pinning3.test
index 220f128..60e073f 100644
--- a/test/pinning3.test
+++ b/test/pinning3.test
@@ -1,2 +1,8 @@
---raw-repository basic.repo --raw-repository +pinning.repo
-a@testing b@testing
+@ARGS
+--test-repo basic.repo
+--test-repo +pinning.repo
+add a@testing b@testing
+@EXPECT
+(1/2) Installing b@testing (3)
+(2/2) Installing a@testing (3)
+OK: 0 MiB in 0 packages
diff --git a/test/pinning4.expect b/test/pinning4.expect
deleted file mode 100644
index 5a03102..0000000
--- a/test/pinning4.expect
+++ /dev/null
@@ -1,3 +0,0 @@
-Installing b (2)
-Installing a (3)
-Installing c (3)
diff --git a/test/pinning4.test b/test/pinning4.test
index 4bf8d38..80348f7 100644
--- a/test/pinning4.test
+++ b/test/pinning4.test
@@ -1,2 +1,9 @@
---raw-repository basic.repo --raw-repository +pinning.repo
-c@testing
+@ARGS
+--test-repo basic.repo
+--test-repo +pinning.repo
+add c@testing
+@EXPECT
+(1/3) Installing b (2)
+(2/3) Installing a@testing (3)
+(3/3) Installing c@testing (3)
+OK: 0 MiB in 0 packages
diff --git a/test/solver.sh b/test/solver.sh
index 20dc232..aa9ffc5 100755
--- a/test/solver.sh
+++ b/test/solver.sh
@@ -1,26 +1,26 @@
#!/bin/sh
-APK_TEST=../src/apk_test
+APK_TEST=../src/apk-test
fail=0
+pass=0
for test in *.test; do
- bn=$(basename $test .test)
- (
- read options
- read world
- $APK_TEST $options "$world" &> $bn.got
- ) < $bn.test
- if ! cmp $bn.expect $bn.got &> /dev/null; then
+ awk '/^@ARGS/{p=1;next} /^@/{p=0} p{print}' < $test | xargs $APK_TEST &> .$test.got
+
+ if ! awk '/^@EXPECT/{p=1;next} /^@/{p=0} p{print}' < $test | cmp .$test.got &> /dev/null; then
fail=$((fail+1))
echo "FAIL: $test"
- diff -ru $bn.expect $bn.got
+ awk '/^@EXPECT/{p=1;next} /^@/{p=0} p{print}' < $test | diff -ru - .$test.got
else
- echo "OK: $test"
+ pass=$((pass+1))
fi
done
+total=$((fail+pass))
if [ "$fail" != "0" ]; then
- echo "FAIL: $fail failed test cases"
+ echo "FAIL: $fail of $total test cases failed"
+else
+ echo "OK: all $total solver test cases passed"
fi
exit $fail