Skip to content

Commit 5dfd2ce

Browse files
committed
Remove unused features from libarchive
Try an integration test with no popen or system
1 parent d69e6ee commit 5dfd2ce

3 files changed

Lines changed: 61 additions & 23 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,16 @@ find_package(LibArchive REQUIRED)
6767
set(WOWPKG_LIBS CURL::libcurl cjson LibArchive::LibArchive)
6868

6969
if (MSVC)
70-
# CMake does not set proper release flags for MSVC.
71-
set(WFLAGS_RELEASE /O2 /GL /DNDEBUG /Zi /Gy)
72-
set(WFLAGS /W4 "$<$<CONFIG:Release>:${WFLAGS_RELEASE}>")
70+
set(WFLAGS_RELEASE /GL /O2)
71+
set(LDFLAGS_RELEASE /LTCG)
72+
73+
# Really only needed if the config is Release.
74+
if(WOWPKG_ENABLE_SANITIZERS)
75+
set(WFLAGS_RELEASE ${WFLAGS_RELEASE} /Zi)
76+
set(LDFLAGS_RELEASE ${LDFLAGS_RELEASE} /DEBUG)
77+
endif()
7378

74-
set(LDFLAGS_RELEASE /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF)
79+
set(WFLAGS /W4 "$<$<CONFIG:Release>:${WFLAGS_RELEASE}>")
7580
set(LDFLAGS "$<$<CONFIG:Release>:${LDFLAGS_RELEASE}>")
7681

7782
# A lot of the functions suggested by this are not available on other

tests/integration/test_integration.c

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
#include <stdlib.h>
66
#include <string.h>
77

8+
#include <curl/curl.h>
9+
810
#include "addon.h"
911
#include "appstate.h"
12+
#include "command.h"
1013
#include "config.h"
1114
#include "context.h"
1215
#include "list.h"
@@ -56,24 +59,51 @@ static bool is_nothing_installed(void)
5659

5760
static void test_install_single(void)
5861
{
59-
assert(system(WOWPKG_EXEC_PATH " install bigwigs") == 0);
60-
assert(!is_addons_dir_empty());
62+
// assert(system(WOWPKG_EXEC_PATH " install bigwigs") == 0);
63+
// assert(!is_addons_dir_empty());
6164

62-
/* Check that installed addons show up in list as expected. */
63-
/*
64-
FILE *fpout = popen(WOWPKG_EXEC_PATH " list", "r");
65-
assert(fpout != NULL);
66-
char pout[32] = { '\0' };
67-
assert(fscanf(fpout, "BigWigs (%31[^)])\n", pout) == 1);
68-
assert(fgetc(fpout) == EOF);
69-
assert(pclose(fpout) == 0);
70-
*/
65+
// /* Check that installed addons show up in list as expected. */
66+
// FILE *fpout = popen(WOWPKG_EXEC_PATH " list", "r");
67+
// assert(fpout != NULL);
68+
// char pout[32] = { '\0' };
69+
// assert(fscanf(fpout, "BigWigs (%31[^)])\n", pout) == 1);
70+
// assert(fgetc(fpout) == EOF);
71+
// assert(pclose(fpout) == 0);
7172

72-
/* Cleanup addons directory. */
73-
/*
74-
assert(system(WOWPKG_EXEC_PATH " remove bigwigs") == 0);
73+
// /* Cleanup addons directory. */
74+
// assert(system(WOWPKG_EXEC_PATH " remove bigwigs") == 0);
75+
// assert(is_addons_dir_empty());
76+
77+
Context ctx = { 0 };
78+
79+
Config *cfg = config_create();
80+
assert(config_load(cfg, WOWPKG_USER_FILE_DIR "/config.ini") == 0);
81+
82+
curl_global_init(CURL_GLOBAL_DEFAULT);
83+
CURL *curl = curl_easy_init();
84+
assert(curl != NULL);
85+
86+
AppState *state = appstate_create();
87+
assert(state != NULL);
88+
89+
ctx.config = cfg;
90+
ctx.curl = curl;
91+
ctx.state = state;
92+
93+
char *install_args[] = { "install", "bigwigs" };
94+
assert(cmd_install(&ctx, ARRAY_SIZE(install_args), install_args, stdout) == 0);
95+
assert(!is_addons_dir_empty());
96+
assert(list_len(ctx.state->installed) == 1);
97+
98+
char *remove_args[] = { "remove", "bigwigs" };
99+
assert(cmd_remove(&ctx, ARRAY_SIZE(remove_args), remove_args, stdout) == 0);
75100
assert(is_addons_dir_empty());
76-
*/
101+
assert(list_len(ctx.state->installed) == 0);
102+
103+
appstate_destroy(state);
104+
curl_easy_cleanup(curl);
105+
curl_global_cleanup();
106+
config_destroy(cfg);
77107
}
78108

79109
static void test_install_multiple(void)
@@ -589,7 +619,7 @@ int main(void)
589619
exit(EXIT_FAILURE);
590620
}
591621

592-
// test_install_single();
622+
test_install_single();
593623
// test_install_multiple();
594624
// test_upgrade_single();
595625
// test_upgrade_all();
@@ -603,7 +633,7 @@ int main(void)
603633

604634
/* This should probably only be ran with GitHub token set, otherwise the rate
605635
* limit is a real concern. */
606-
test_install_all();
636+
// test_install_all();
607637

608638
return EXIT_SUCCESS;
609639
}

vcpkg.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"dependencies": [
55
"cjson",
66
"curl",
7-
"libarchive"
7+
{
8+
"name": "libarchive",
9+
"default-features": false
10+
}
811
]
9-
}
12+
}

0 commit comments

Comments
 (0)