mirror of
https://github.com/thepigeongenerator/mcaselector-lite
synced 2026-02-08 07:33:35 +01:00
Remove /test and /.github, the CI/testing framework.
The unit tests and continious integration is... exessive. Yes, it's useful, but creates more complications than that it helps, so it is removed for the time being. Maybe I will add a new framework at a later date, but at the moment it is constraining development.
This commit is contained in:
62
.github/workflows/ci.yaml
vendored
62
.github/workflows/ci.yaml
vendored
@@ -1,62 +0,0 @@
|
|||||||
# This file is part of MCA-Selector-lite,
|
|
||||||
# and is licensed under GPL-2.0-only.
|
|
||||||
# Copyright (C)2025 quinnthepigeon@proton.me Quinn
|
|
||||||
# For further information, view COPYING and CONTRIBUTORS
|
|
||||||
# at: www.github.com/thepigeongenerator/mcaselector-lite
|
|
||||||
name: CI
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
compile-and-test:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false # disable fail fast, so feedback is provided for all matrix combinations
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: ubuntu-latest
|
|
||||||
cc: cc
|
|
||||||
- os: ubuntu-24.04-arm
|
|
||||||
cc: cc
|
|
||||||
- os: windows-latest
|
|
||||||
cc: gcc
|
|
||||||
- os: windows-11-arm
|
|
||||||
cc: gcc
|
|
||||||
# - os: macos-latest
|
|
||||||
# cc: cc
|
|
||||||
env:
|
|
||||||
CC: ${{matrix.cc}}
|
|
||||||
runs-on: ${{matrix.os}}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: "Linux: install deps"
|
|
||||||
if: runner.os == 'Linux'
|
|
||||||
run: |
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install -y libwayland-dev libxkbcommon-dev xorg-dev cmake xxd
|
|
||||||
|
|
||||||
- name: get submodule hash
|
|
||||||
id: get-hash
|
|
||||||
run: echo "HASH=$(git submodule | sha1sum | cut -d' ' -f1)" >$GITHUB_OUTPUT
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
|
||||||
id: cache-deps
|
|
||||||
with:
|
|
||||||
path: lib/obj/
|
|
||||||
# I swear to god, if runner.arch displays x64 for x86_64, I will eat a potato.
|
|
||||||
# note: it is... fucking shit.
|
|
||||||
key: ${{runner.os}}_${{runner.arch}}-lib/obj-${{steps.get-hash.outputs.HASH}}
|
|
||||||
restore-keys: ${{runner.os}}_${{runner.arch}}-lib/obj-
|
|
||||||
|
|
||||||
- run: make -Bj libs
|
|
||||||
if: steps.cache-deps.outputs.cache-hit != 'true' && runner.os != 'Windows'
|
|
||||||
- run: make -Bj2 libs # compile fewer cores, to save memory.
|
|
||||||
if: steps.cache-deps.outputs.cache-hit != 'true' && runner.os == 'Windows'
|
|
||||||
|
|
||||||
- run: make -j all
|
|
||||||
- run: make -j check
|
|
||||||
@@ -7,8 +7,6 @@ A from-scratch rewrite of [mcaselector](https://github.com/Querz/mcaselector) in
|
|||||||
[](https://github.com/thepigeongenerator/mcaselector-lite/blob/main/LICENSE)
|
[](https://github.com/thepigeongenerator/mcaselector-lite/blob/main/LICENSE)
|
||||||
[](https://github.com/thepigeongenerator/mcaselector-lite/issues/)
|
[](https://github.com/thepigeongenerator/mcaselector-lite/issues/)
|
||||||
|
|
||||||
[](https://github.com/thepigeongenerator/mcaselector-lite/actions/workflows/ci.yaml)
|
|
||||||
|
|
||||||
## what does it do
|
## what does it do
|
||||||
MCA selector lite is a tool used to edit [region files](https://minecraft.wiki/w/Region_file_format) of your [Minecraft java](https://minecraft.wiki/w/Java_Edition) worlds.
|
MCA selector lite is a tool used to edit [region files](https://minecraft.wiki/w/Region_file_format) of your [Minecraft java](https://minecraft.wiki/w/Java_Edition) worlds.
|
||||||
This is useful for reducing world size, general world management, perhaps copying chunks from one world to another or various other administrative tasks.
|
This is useful for reducing world size, general world management, perhaps copying chunks from one world to another or various other administrative tasks.
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ static const char *strmat(const char *s1, const char *s2)
|
|||||||
return s1;
|
return s1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int conf_getkeyval(const char *restrict buf, const char *const restrict *restrict keys, int klen, const char *restrict *restrict out)
|
int conf_getkeyval(const char *restrict buf,
|
||||||
|
const char *const restrict *restrict keys, int klen,
|
||||||
|
const char *restrict *restrict out)
|
||||||
{
|
{
|
||||||
const char *tmp = NULL;
|
const char *tmp = NULL;
|
||||||
|
|
||||||
|
|||||||
57
test/main.c
57
test/main.c
@@ -1,57 +0,0 @@
|
|||||||
/* This file is part of MCA-Selector-lite,
|
|
||||||
* and is licensed under GPL-2.0-only.
|
|
||||||
* Copyright (C)2025 quinnthepigeon@proton.me Quinn
|
|
||||||
* For further information, view COPYING and CONTRIBUTORS
|
|
||||||
* at: www.github.com/thepigeongenerator/mcaselector-lite */
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "test.h"
|
|
||||||
#include "test_conf.h"
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
assert_true(-3 >> 5 == -1); // checking for arithmetic shift, rather than logical shift
|
|
||||||
assert_true(sizeof(u8) == 1);
|
|
||||||
assert_true(sizeof(u16) == 2);
|
|
||||||
assert_true(sizeof(u32) == 4);
|
|
||||||
assert_true(sizeof(u64) == 8);
|
|
||||||
assert_true(sizeof(f32) == 4);
|
|
||||||
assert_true(sizeof(f64) == 8);
|
|
||||||
assert_true(sizeof(usize) == sizeof(size_t));
|
|
||||||
test_conf_procbuf("key=val", "key", "val", 0);
|
|
||||||
test_conf_procbuf("sometxt", "sometxt", "", CONF_ESYNTAX);
|
|
||||||
test_conf_procbuf("# comment", "", "", CONF_ENODAT);
|
|
||||||
test_conf_procbuf("", "", "", CONF_ENODAT);
|
|
||||||
test_conf_procbuf("\n", "", "", CONF_ENODAT);
|
|
||||||
test_conf_procbuf("\r\n", "", "", CONF_ENODAT);
|
|
||||||
test_conf_procbuf("k=v\na", "k", "v", 0);
|
|
||||||
test_conf_procbuf("k=v\r\na", "k", "v", 0);
|
|
||||||
test_conf_getpat();
|
|
||||||
|
|
||||||
struct conf_entry opts[] = {
|
|
||||||
{"key0", NULL, 0},
|
|
||||||
{"key1", NULL, 0},
|
|
||||||
{"key2", NULL, 0}
|
|
||||||
};
|
|
||||||
test_conf_matchopt(opts, 3, "key0", 0);
|
|
||||||
test_conf_matchopt(opts, 3, "key1", 1);
|
|
||||||
test_conf_matchopt(opts, 3, "key2", 2);
|
|
||||||
test_conf_matchopt(opts, 3, "key3", -1);
|
|
||||||
|
|
||||||
test_conf_procval_int("42", 42, CONF_I32);
|
|
||||||
test_conf_procval_int("-42", (u32)-42, CONF_I32);
|
|
||||||
test_conf_procval_int("4294967295", UINT32_MAX, CONF_U32);
|
|
||||||
test_conf_procval_int("9223372036854775807", INT64_MAX, CONF_I64);
|
|
||||||
test_conf_procval_int("256", 255, CONF_U8);
|
|
||||||
|
|
||||||
// TODO: write more tests for float parsing
|
|
||||||
test_conf_procval_f32("0.0", 0.0f);
|
|
||||||
test_conf_procval_f32("3.14159", 3.14159f);
|
|
||||||
test_conf_procval_f32("3.1428571428", 22.0f / 7.0f);
|
|
||||||
test_conf_procval_f32("-5.0", -5.0f);
|
|
||||||
|
|
||||||
/* return 1 if there were failed tests. */
|
|
||||||
printf("test results: (%u/%u)\n", test_okay, test_okay + test_fail);
|
|
||||||
return !!test_fail;
|
|
||||||
}
|
|
||||||
23
test/test.c
23
test/test.c
@@ -1,23 +0,0 @@
|
|||||||
/* This file is part of MCA-Selector-lite,
|
|
||||||
* and is licensed under GPL-2.0-only.
|
|
||||||
* Copyright (C)2025 quinnthepigeon@proton.me Quinn
|
|
||||||
* For further information, view COPYING and CONTRIBUTORS
|
|
||||||
* at: www.github.com/thepigeongenerator/mcaselector-lite */
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
#include "../src/types.h"
|
|
||||||
|
|
||||||
uint test_okay = 0;
|
|
||||||
uint test_fail = 0;
|
|
||||||
|
|
||||||
int test_process(int res, const char *restrict file, uint ln, const char *restrict function, const char *restrict expression)
|
|
||||||
{
|
|
||||||
const char *status = res ?
|
|
||||||
"[\033[32;1m OK \033[0m]" :
|
|
||||||
"[\033[31;1m FAIL \033[0m]";
|
|
||||||
test_okay += !!res;
|
|
||||||
test_fail += !res;
|
|
||||||
|
|
||||||
printf("%s\t%s:%u-%s\t-> %s\n", status, file, ln, function, expression);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
19
test/test.h
19
test/test.h
@@ -1,19 +0,0 @@
|
|||||||
/* This file is part of MCA-Selector-lite,
|
|
||||||
* and is licensed under GPL-2.0-only.
|
|
||||||
* Copyright (C)2025 quinnthepigeon@proton.me Quinn
|
|
||||||
* For further information, view COPYING and CONTRIBUTORS
|
|
||||||
* at: www.github.com/thepigeongenerator/mcaselector-lite */
|
|
||||||
#pragma once
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "../src/types.h"
|
|
||||||
|
|
||||||
extern uint test_okay;
|
|
||||||
extern uint test_fail;
|
|
||||||
|
|
||||||
/* Prints the result `res` of a test.
|
|
||||||
* Returns `res` back, for ease of chaining. */
|
|
||||||
int test_process(int res, const char *restrict file, uint ln, const char *restrict function, const char *restrict expression);
|
|
||||||
|
|
||||||
#define assert_true(expr) test_process((expr), __FILE__, __LINE__, __func__, #expr)
|
|
||||||
#define assert_false(expr) assert_true(!(expr))
|
|
||||||
144
test/test_conf.c
144
test/test_conf.c
@@ -1,144 +0,0 @@
|
|||||||
/* This file is part of MCA-Selector-lite,
|
|
||||||
* and is licensed under GPL-2.0-only.
|
|
||||||
* Copyright (C)2025 quinnthepigeon@proton.me Quinn
|
|
||||||
* For further information, view COPYING and CONTRIBUTORS
|
|
||||||
* at: www.github.com/thepigeongenerator/mcaselector-lite */
|
|
||||||
#include "test_conf.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "../src/types.h"
|
|
||||||
#include "../src/util/conf.h"
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
void test_conf_procbuf(const char *restrict buf, const char *restrict expect_key, const char *restrict expect_val, int expect_return)
|
|
||||||
{
|
|
||||||
usize len = strlen(buf) + 1;
|
|
||||||
char k[len], v[len];
|
|
||||||
*k = '\0', *v = '\0';
|
|
||||||
(void)(assert_true(conf_procbuf(buf, k, v, len) == expect_return) &&
|
|
||||||
assert_true(!strcmp(k, expect_key)) &&
|
|
||||||
assert_true(!strcmp(v, expect_val)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_conf_matchopt(struct conf_entry *opts, usize optc, const char *restrict key, int expect_index)
|
|
||||||
{
|
|
||||||
usize idx = opts - conf_matchopt(opts, optc, key);
|
|
||||||
idx = (ssize)idx < 0 ? -idx : idx;
|
|
||||||
int i = idx < optc ? (int)idx : -1;
|
|
||||||
assert_true(i == expect_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_conf_procval_int(const char *val, u64 expect_value, int type)
|
|
||||||
{
|
|
||||||
u8 out[sizeof(u64)] = {0};
|
|
||||||
assert_true(!conf_procval(&(struct conf_entry){NULL, out, type}, val));
|
|
||||||
assert_true(memcmp(out, &expect_value, sizeof(u64)) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_conf_procval_f32(const char *val, f32 expect_value)
|
|
||||||
{
|
|
||||||
u8 out[4];
|
|
||||||
f32 result;
|
|
||||||
conf_procval(&(struct conf_entry){NULL, out, CONF_F32}, val);
|
|
||||||
memcpy(&result, out, 4);
|
|
||||||
assert_true(fabsf(expect_value - result) < 1e-9f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_procval_str(void)
|
|
||||||
{
|
|
||||||
char *out = NULL;
|
|
||||||
(void)(assert_true(!conf_procval(&(struct conf_entry){NULL, (void *)&out, CONF_STR}, "here comes the sowon")) &&
|
|
||||||
assert_false(strcmp("here comes the sowon", out)));
|
|
||||||
free(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_procval_str_predef(void)
|
|
||||||
{
|
|
||||||
char *out = strdup("owo");
|
|
||||||
(void)(assert_true(!conf_procval(&(struct conf_entry){NULL, (void *)&out, CONF_STR}, "i leak if I don't free")) &&
|
|
||||||
assert_true(!strcmp("i leak if I don't free", out)));
|
|
||||||
free(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_procval_fstr(void)
|
|
||||||
{
|
|
||||||
char buf[16];
|
|
||||||
struct conf_fstr str = {sizeof(buf), buf};
|
|
||||||
(void)(assert_true(!conf_procval(&(struct conf_entry){NULL, &str, CONF_FSTR}, "hewwoo wowld")) &&
|
|
||||||
assert_true(!strcmp(str.out, "hewwoo wowld")));
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_procval_fstr_trunc(void)
|
|
||||||
{
|
|
||||||
char buf[8];
|
|
||||||
struct conf_fstr str = {sizeof(buf), buf};
|
|
||||||
(void)(assert_true(!conf_procval(&(struct conf_entry){NULL, &str, CONF_FSTR}, "hewwooo wowld")) &&
|
|
||||||
assert_true(!strcmp(str.out, "hewwooo")));
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_procval_eparse(void)
|
|
||||||
{
|
|
||||||
i32 out;
|
|
||||||
assert_true(conf_procval(&(struct conf_entry){NULL, &out, CONF_I32}, "owo") == CONF_EPARSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_conf_getpat(void)
|
|
||||||
{
|
|
||||||
char *path;
|
|
||||||
#if defined(__linux__)
|
|
||||||
/* test without setting environment variables. */
|
|
||||||
unsetenv("XDG_CONFIG_HOME");
|
|
||||||
unsetenv("HOME");
|
|
||||||
path = conf_getpat("/mypath");
|
|
||||||
assert_true(path == NULL);
|
|
||||||
free(path);
|
|
||||||
|
|
||||||
/* test with setting HOME. */
|
|
||||||
setenv("HOME", "/home/test", 1);
|
|
||||||
path = conf_getpat("/mypath");
|
|
||||||
assert_true(path != NULL && strcmp(path, "/home/test/.config/mypath") == 0);
|
|
||||||
free(path);
|
|
||||||
conf_getpat("/mypath");
|
|
||||||
|
|
||||||
/* test with setting XDG_CONFIG_HOME. */
|
|
||||||
setenv("XDG_CONFIG_HOME", "/etc/xdg", 1);
|
|
||||||
path = conf_getpat("/mypath");
|
|
||||||
assert_true(path != NULL && strcmp(path, "/etc/xdg/mypath") == 0);
|
|
||||||
free(path);
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
/* test without setting environment variables. */
|
|
||||||
unsetenv("HOME");
|
|
||||||
path = conf_getpat("/mypath");
|
|
||||||
assert_true(path == NULL);
|
|
||||||
free(path);
|
|
||||||
|
|
||||||
/* test with setting HOME. */
|
|
||||||
setenv("HOME", "/home/test", 1);
|
|
||||||
path = conf_getpat("/mypath");
|
|
||||||
assert_true(path != NULL && strcmp(path, "/home/test/Library/Application Support/mypath") == 0);
|
|
||||||
free(path);
|
|
||||||
#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
|
|
||||||
/* test without setting environment variables. */
|
|
||||||
_putenv("APPDATA=");
|
|
||||||
_putenv("USERPROFILE=");
|
|
||||||
path = conf_getpat("\\mypath");
|
|
||||||
assert_true(path == NULL);
|
|
||||||
free(path);
|
|
||||||
|
|
||||||
/* test with setting USERPROFILE */
|
|
||||||
_putenv("USERPROFILE=C:\\Users\\test");
|
|
||||||
path = conf_getpat("\\mypath");
|
|
||||||
assert_true(path != NULL && strcmp(path, "C:\\Users\\test\\AppData\\Roaming\\mypath") == 0);
|
|
||||||
free(path);
|
|
||||||
|
|
||||||
/* test with setting APPDATA */
|
|
||||||
_putenv("APPDATA=C:\\Users\\test\\AppData\\Roaming");
|
|
||||||
path = conf_getpat("\\mypath");
|
|
||||||
assert_true(path != NULL && strcmp(path, "C:\\Users\\test\\AppData\\Roaming\\mypath") == 0);
|
|
||||||
free(path);
|
|
||||||
#else
|
|
||||||
assert_fail("unsupported operating system; no tests have been written.");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/* This file is part of MCA-Selector-lite,
|
|
||||||
* and is licensed under GPL-2.0-only.
|
|
||||||
* Copyright (C)2025 quinnthepigeon@proton.me Quinn
|
|
||||||
* For further information, view COPYING and CONTRIBUTORS
|
|
||||||
* at: www.github.com/thepigeongenerator/mcaselector-lite */
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../src/types.h"
|
|
||||||
#include "../src/util/conf.h"
|
|
||||||
|
|
||||||
void test_conf_procbuf(const char *restrict buf, const char *restrict expect_key, const char *restrict expect_val, int expect_return);
|
|
||||||
void test_conf_matchopt(struct conf_entry *restrict opts, usize optc, const char *restrict key, int expect_index);
|
|
||||||
void test_conf_procval_int(const char *val, u64 expect_value, int type);
|
|
||||||
void test_conf_procval_f32(const char *val, f32 expect_value);
|
|
||||||
void test_conf_procval_fstr(const char *val, u64 expect_value, int type);
|
|
||||||
void test_conf_procval_str(const char *val, u64 expect_value, int type);
|
|
||||||
void test_procval_str(void);
|
|
||||||
void test_procval_str_predef(void);
|
|
||||||
void test_procval_fstr(void);
|
|
||||||
void test_procval_fstr_trunc(void);
|
|
||||||
void test_procval_eparse(void);
|
|
||||||
void test_conf_getpat(void);
|
|
||||||
Reference in New Issue
Block a user