libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit e7b2d34108074a2beb69a60b6d459715ec061002
parent 33e8028ee997dd6447a43881daf66d285f9dfcce
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 24 May 2017 19:09:03 +0200

Fix(Tests): Fix tests for compilation

Diffstat:
Msrc/packer.c | 2+-
Mtests/test_compile.c | 5+++--
Mtests/test_packer.c | 12++++++++++--
3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/packer.c b/src/packer.c @@ -847,7 +847,7 @@ bool packer_extract_archive(packer_t *ctx, const char *dir) { asprintf(&ctx->out_dir, "%s/%s-%s/", dir, ctx->header->package->name, ctx->header->package->version); - if (mkdir(ctx->out_dir, S_IRWXU | S_IRWXG | S_IRWXO) == -1 && errno != EEXIST) + if (mkdir(ctx->out_dir, S_IRWXU | S_IRWXG | S_IRWXO) == -1) goto cleanup; chdir(ctx->out_dir); diff --git a/tests/test_compile.c b/tests/test_compile.c @@ -5,7 +5,8 @@ TEST(init_compile) { packer_t *ptr; - ptr = packer_init_dir("packer/compilation//"); + set_mkdir_fail(-1); + ptr = packer_init_dir("packer/compilation/"); TEST_ASSERT(packer_read_dir(ptr) == true, "An error happened"); TEST_ASSERT(packer_create_archive(ptr, PACKAGE_OUTPUT_FN) == true, "An error happened"); @@ -18,7 +19,7 @@ TEST(configure_package) { packer_t *ctx = packer_init_archive(PACKAGE_OUTPUT_FN); compile_t *ptr = NULL; - packer_extract_archive(ctx, "/tmp"); + TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); TEST_ASSERT(before_package(ptr) == true, "An error happened"); diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -1,5 +1,11 @@ #include "test.h" +TEST(packer_tests_init) { + /* Cleaning tests directory */ + recursive_delete("/tmp/test-2.0"); + return TEST_SUCCESS; +} + TEST(packer_init_dir) { packer_t *ptr = NULL; @@ -614,7 +620,7 @@ TEST(packer_extract_archive_2) { packer_free(ctx); ctx = packer_init_archive(PACKAGE_OUTPUT_FN); - set_mkdir_fail(1); + set_mkdir_fail(2); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == false, "Error did not raise"); packer_free(ctx); @@ -622,12 +628,14 @@ TEST(packer_extract_archive_2) { } TEST(packer_create_archive_cleanup) { + recursive_delete("/tmp/test-2.0"); unlink(PACKAGE_OUTPUT_FN); return TEST_SUCCESS; } void register_test_packer(void) { - reg_test("packer", packer_init_dir); + reg_test("packer", packer_tests_init); + reg_test("packer", packer_init_dir); reg_test("packer", packer_init_archive); reg_test("packer", packer_read_dir_wrong_type); reg_test("packer", packer_read_dir_wrong_dir);