feat: some python packages

This commit is contained in:
2025-04-05 17:04:29 +00:00
parent 34c798b222
commit 686344e356
9 changed files with 351 additions and 63 deletions

124
flake.nix
View File

@@ -72,6 +72,50 @@
}; };
}; };
in { in {
"python3.asyncio" = pkgs.python3Packages.buildPythonPackage rec {
pname = "asyncio";
version = "3.4.3";
src = pkgs.python3Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-gzYP+LyXmA5P8lyWTHvTkj0zPRd6pPf7c2sBnybHy0E=";
};
};
"python3.cryptomus" = pkgs.python3Packages.buildPythonPackage rec {
pname = "cryptomus";
version = "1.1";
src = pkgs.python3Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-f0BBGfemKxMdz+LMvawWqqRfmF+TrCpMwgtJEYt+fgU=";
};
};
"python3.modulegraph" = pkgs.python3Packages.buildPythonPackage rec {
pname = "modulegraph";
version = "0.19.6";
src = pkgs.python3Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-yRTIyVoOEP6IUF1OnCKEtOPbxwlD4wbMZWfjbMVBv0s=";
};
};
"python3.swifter" = pkgs.python3Packages.buildPythonPackage rec {
pname = "swifter";
version = "1.4.0";
src = pkgs.python3Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-4bt0R2ohs/B6F6oYyX/cuoWZcmvRfacy8J2rzFDia6A=";
};
};
"python3.aiogram-newsletter" = pkgs.python3Packages.buildPythonPackage rec {
pname = "aiogram-newsletter";
version = "0.0.10";
src = pkgs.fetchFromGitHub {
inherit pname version;
owner = "nessshon";
repo = "aiogram-newsletter";
rev = "bb8a42e4bcff66a9a606fc92ccc27b1d094b20fc";
sha256 = "sha256-atKhccp8Pr8anJUo+M9hnYkYrcgnB9SxrpmsiVusJZs=";
};
};
nvim-alias = pkgs.callPackage ./package/nvim-alias.nix {}; nvim-alias = pkgs.callPackage ./package/nvim-alias.nix {};
bolt-unpack = pkgs.callPackage ./package/bolt-unpack.nix {}; bolt-unpack = pkgs.callPackage ./package/bolt-unpack.nix {};
nvim-pager = pkgs.callPackage ./package/nvim-pager.nix {}; nvim-pager = pkgs.callPackage ./package/nvim-pager.nix {};
@@ -85,19 +129,20 @@
pg-from = pkgs.callPackage ./package/postgres/pg-from/default.nix rust.commonArgs; pg-from = pkgs.callPackage ./package/postgres/pg-from/default.nix rust.commonArgs;
pg-schema = pkgs.callPackage ./package/postgres/pg-schema/default.nix rust.commonArgs; pg-schema = pkgs.callPackage ./package/postgres/pg-schema/default.nix rust.commonArgs;
pg-migration = pkgs.callPackage ./package/postgres/pg-migration/default.nix rust.commonArgs; pg-migration = pkgs.callPackage ./package/postgres/pg-migration/default.nix rust.commonArgs;
hectic = pkgs.callPackage ./package/c/hectic/default.nix {}; "c.hectic" = pkgs.callPackage ./package/c/hectic/default.nix {};
watch = pkgs.callPackage ./package/c/watch/default.nix {};
hmpl = pkgs.callPackage ./package/c/hmpl/default.nix { hmpl = pkgs.callPackage ./package/c/hmpl/default.nix {
hectic = self.packages.${system}.hectic; hectic = self.packages.${system}.hectic;
}; };
}; };
devShells.${system} = let devShells.${system} = let
shells = self.devShells.${system}; shells = self.devShells.${system};
in { in {
c = pkgs.mkShell { c = pkgs.mkShell {
buildInputs = (with pkgs; [ gdb gcc ]) ++ (with self.packages.${system}; [ hectic nvim-pager]); buildInputs = (with pkgs; [ inotify-tools gdb gcc ]) ++ (with self.packages.${system}; [ hectic nvim-pager watch ]);
PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; PAGER = "${self.packages.${system}.nvim-pager}/bin/pager";
}; };
default = pkgs.mkShell { default = pkgs.mkShell {
buildInputs = buildInputs =
(with self.packages.${system}; [ (with self.packages.${system}; [
@@ -147,40 +192,39 @@
users.users.root.openssh.authorizedKeys.keys = [ ]; users.users.root.openssh.authorizedKeys.keys = [ ];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(pkgs.writers.writeMinCBin "minc-hello-world" ["<stdio.h>"] /*c*/ '' (pkgs.writers.writeMinCBin "minc-hello-world" ["<stdio.h>"] /*c*/ ''
printf("hello world\n"); printf("hello world\n");
'') '')
(pkgs.writers.writeMinCBin "minc-env" ["<stdio.h>" "<stdlib.h>"] /*c*/ '' (pkgs.writers.writeMinCBin "minc-env" ["<stdio.h>" "<stdlib.h>"] /*c*/ ''
char *env_name; char *env_name;
if (argc > 1) { if (argc > 1) {
env_name = argv[1]; env_name = argv[1];
} else { } else {
env_name = "HOME"; env_name = "HOME";
} }
char *value = getenv(env_name); char *value = getenv(env_name);
if (value) { if (value) {
printf("%s: %s\n", env_name, value); printf("%s: %s\n", env_name, value);
} else { } else {
printf("Environment variable %s not found.\n", env_name); printf("Environment variable %s not found.\n", env_name);
} }
'') '')
(pkgs.writers.writeMinCBin "minc-env-check" ["<stdio.h>" "<stdlib.h>"] /*c*/ '' (pkgs.writers.writeMinCBin "minc-env-check" ["<stdio.h>" "<stdlib.h>"] /*c*/ ''
char *env_name; char *env_name;
if (argc > 1) { if (argc > 1) {
env_name = argv[1]; env_name = argv[1];
} else { } else {
env_name = "HOME"; env_name = "HOME";
} }
char *value = getenv(env_name); char *value = getenv(env_name);
if (value) { if (value) {
char buffer[128]; char buffer[128];
sprintf(buffer, "echo $%s\n", env_name); sprintf(buffer, "echo $%s\n", env_name);
system(buffer); system(buffer);
} else { } else {
printf("Environment variable %s not found.\n", env_name); printf("Environment variable %s not found.\n", env_name);
} }
'') '')
]; ];
programs.zsh.shellAliases = { programs.zsh.shellAliases = {
jc = ''journalctl''; jc = ''journalctl'';
@@ -343,7 +387,7 @@
cargoHash = "sha256-AbLT7vcFV89zwZIaTC1ELat9l4UeNP8Bn9QMMOms1Co="; cargoHash = "sha256-AbLT7vcFV89zwZIaTC1ELat9l4UeNP8Bn9QMMOms1Co=";
doCheck = false; doCheck = false;
}; };
buildHttpExt = versionSuffix: buildHttpExt = versionSuffix:
buildPostgresqlExtension { buildPostgresqlExtension {
postgresql = prev."postgresql_${versionSuffix}"; postgresql = prev."postgresql_${versionSuffix}";
@@ -361,14 +405,14 @@
in { in {
hectic = self.packages.${prev.system}; hectic = self.packages.${prev.system};
postgresql_17 = prev.postgresql_17 // {pkgs = prev.postgresql_17.pkgs // { postgresql_17 = prev.postgresql_17 // {pkgs = prev.postgresql_17.pkgs // {
http = buildHttpExt "17"; http = buildHttpExt "17";
pg_smtp_client = buildSmtpExt "17"; pg_smtp_client = buildSmtpExt "17";
};}; };};
postgresql_16 = prev.postgresql_16 // {pkgs = prev.postgresql_16.pkgs // { postgresql_16 = prev.postgresql_16 // {pkgs = prev.postgresql_16.pkgs // {
http = buildHttpExt "16"; http = buildHttpExt "16";
pg_smtp_client = buildSmtpExt "16"; pg_smtp_client = buildSmtpExt "16";
};}; };};
writers = let writers = let
writeC = writeC =
name: argsOrScript: name: argsOrScript:
if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript then if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript then
@@ -397,7 +441,7 @@
${prev.gcc}/bin/gcc -xc -o $out $contentPath ${prev.gcc}/bin/gcc -xc -o $out $contentPath
''; '';
} name argsOrScript; } name argsOrScript;
writeMinC = writeMinC =
name: includes: body: name: includes: body:
writeC name '' writeC name ''
${builtins.concatStringsSep "\n" (map (h: "#include " + h) includes)} ${builtins.concatStringsSep "\n" (map (h: "#include " + h) includes)}
@@ -406,20 +450,20 @@
${body} ${body}
} }
''; '';
in prev.writers // { in prev.writers // {
writeCBin = name: writeC "/bin/${name}"; writeCBin = name: writeC "/bin/${name}";
writeC = writeC; writeC = writeC;
writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body; writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body;
writeMinC = writeMinC; writeMinC = writeMinC;
}; };
postgresql_15 = prev.postgresql_15 // {pkgs = prev.postgresql_15.pkgs // { postgresql_15 = prev.postgresql_15 // {pkgs = prev.postgresql_15.pkgs // {
http = buildHttpExt "15"; http = buildHttpExt "15";
pg_smtp_client = buildSmtpExt "15"; pg_smtp_client = buildSmtpExt "15";
};}; };};
postgresql_14 = prev.postgresql_14 // {pkgs = prev.postgresql_14.pkgs // { postgresql_14 = prev.postgresql_14 // {pkgs = prev.postgresql_14.pkgs // {
http = buildHttpExt "14"; http = buildHttpExt "14";
pg_smtp_client = buildSmtpExt "14"; pg_smtp_client = buildSmtpExt "14";
};}; };};
} }
); );
lib = { lib = {

View File

@@ -23,14 +23,14 @@ const char* log_level_to_string(LogLevel level) {
const char* log_level_to_color(LogLevel level) { const char* log_level_to_color(LogLevel level) {
switch (level) { switch (level) {
case LOG_LEVEL_TRACE: return COLOR_GREEN; case LOG_LEVEL_TRACE: return OPTIONAL_COLOR(COLOR_GREEN);
case LOG_LEVEL_DEBUG: return COLOR_BLUE; case LOG_LEVEL_DEBUG: return OPTIONAL_COLOR(COLOR_BLUE);
case LOG_LEVEL_LOG: return COLOR_CYAN; case LOG_LEVEL_LOG: return OPTIONAL_COLOR(COLOR_CYAN);
case LOG_LEVEL_INFO: return COLOR_GREEN; case LOG_LEVEL_INFO: return OPTIONAL_COLOR(COLOR_GREEN);
case LOG_LEVEL_NOTICE: return COLOR_CYAN; case LOG_LEVEL_NOTICE: return OPTIONAL_COLOR(COLOR_CYAN);
case LOG_LEVEL_WARN: return COLOR_YELLOW; case LOG_LEVEL_WARN: return OPTIONAL_COLOR(COLOR_YELLOW);
case LOG_LEVEL_EXCEPTION: return COLOR_RED; case LOG_LEVEL_EXCEPTION: return OPTIONAL_COLOR(COLOR_RED);
default: return COLOR_RESET; default: return OPTIONAL_COLOR(COLOR_RESET);
} }
} }
@@ -87,7 +87,7 @@ char* raise_message(
static char timeStr[20]; static char timeStr[20];
strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", &tm_info); strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", &tm_info);
fprintf(stderr, "%s %s%s%s %s:%d ", timeStr, log_level_to_color(level), log_level_to_string(level), COLOR_RESET, file, line); fprintf(stderr, "%s %s%s%s %s:%d ", timeStr, log_level_to_color(level), log_level_to_string(level), OPTIONAL_COLOR(COLOR_RESET), file, line);
va_list args; va_list args;
va_start(args, format); va_start(args, format);

View File

@@ -74,12 +74,14 @@ void hmpl_render_section_tags(Arena *arena, char **text_ptr, Json *context, cons
char start_pattern[32]; char start_pattern[32];
snprintf(start_pattern, sizeof(start_pattern), "{{%s", prefix_start); snprintf(start_pattern, sizeof(start_pattern), "{{%s", prefix_start);
Slice start_slice = slice_create(char, start_pattern, strlen(start_pattern), 0, strlen(start_pattern)); Slice start_slice = slice_create(char, start_pattern, strlen(start_pattern), 0, strlen(start_pattern));
raise_trace("start_slice: %s", start_slice.data);
// Create a mutable copy of separator_pattern // Create a mutable copy of separator_pattern
char separator_copy[32]; char separator_copy[32];
strncpy(separator_copy, separator_pattern, sizeof(separator_copy) - 1); strncpy(separator_copy, separator_pattern, sizeof(separator_copy) - 1);
separator_copy[sizeof(separator_copy) - 1] = '\0'; separator_copy[sizeof(separator_copy) - 1] = '\0';
Slice separator_slice = slice_create(char, separator_copy, strlen(separator_copy), 0, strlen(separator_copy)); Slice separator_slice = slice_create(char, separator_copy, strlen(separator_copy), 0, strlen(separator_copy));
raise_trace("separator_slice: %s", separator_slice.data);
if (separator_slice.len == 0) { if (separator_slice.len == 0) {
raise_exception("Unexpected usage: separator pattern cannot be empty"); raise_exception("Unexpected usage: separator pattern cannot be empty");
} }
@@ -134,6 +136,7 @@ void hmpl_render_section_tags(Arena *arena, char **text_ptr, Json *context, cons
char *close_tag_pattern = arena_alloc(arena, start_slice.len + key_length + 3); // +3 for "{{" and "}}" char *close_tag_pattern = arena_alloc(arena, start_slice.len + key_length + 3); // +3 for "{{" and "}}"
snprintf(close_tag_pattern, start_slice.len + key_length + 3, snprintf(close_tag_pattern, start_slice.len + key_length + 3,
"{{%s%s}}", prefix_end, key); "{{%s%s}}", prefix_end, key);
raise_trace("close_tag_pattern: %s", close_tag_pattern);
// Find closing tag // Find closing tag
size_t after_opening_end = (opening_tag_end - (char*)after_separator.data) + 2; size_t after_opening_end = (opening_tag_end - (char*)after_separator.data) + 2;

View File

@@ -107,7 +107,7 @@ case "$MODE" in
# shellcheck disable=SC2086 # shellcheck disable=SC2086
cc $CFLAGS $OPTFLAGS -pedantic -I. "$test_file" -Ltarget -lhmpl $LDFLAGS -o "$exe" cc $CFLAGS $OPTFLAGS -pedantic -I. "$test_file" -Ltarget -lhmpl $LDFLAGS -o "$exe"
if [ "$RUN_TESTS" -eq 1 ]; then if [ "$RUN_TESTS" -eq 1 ]; then
"$exe" LOG_LEVEL=TRACE ./"$exe"
fi fi
done done
;; ;;

View File

@@ -0,0 +1,30 @@
{ stdenv, gcc, lib, bash, inotify-tools }:
stdenv.mkDerivation {
pname = "prettify";
version = "1.0";
src = ./.;
doCheck = false;
nativeBuildInputs = [ gcc ];
buildPhase = ''
ls
${bash}/bin/sh ./make.sh build
'';
checkPhase = ''
${bash}/bin/sh ./make.sh check
'';
installPhase = ''
mkdir -p $out/lib $out/include
cp target/libhectic.a $out/lib/
cp hectic.h $out/include/
'';
meta = {
description = "prettify";
license = lib.licenses.mit;
};
}

95
package/c/prettify/main.c Executable file
View File

@@ -0,0 +1,95 @@
#include <stdio.h>
#include <string.h>
#include <hectic.h>
#include <strings.h>
#include <stdlib.h>
#include <getopt.h>
#define MAX_LINE 1024
typedef struct {
const char *keyword;
const char *color;
} KeywordColor;
static KeywordColor keyword_colors[] = {
{"LOG", COLOR_GREEN},
{"DEBUG", COLOR_BLUE},
{"ERROR", COLOR_RED},
{"INFO", COLOR_GREEN},
{"WARNING", COLOR_YELLOW},
{"NOTICE", COLOR_CYAN},
{"HINT", COLOR_MAGENTA},
{"DETAIL", COLOR_CYAN},
{"STATEMENT", COLOR_CYAN},
{"EXCEPTION", COLOR_MAGENTA},
{"FATAL", COLOR_MAGENTA},
};
void print_usage(const char *prog_name) {
fprintf(stderr, "Usage: %s [options]\n", prog_name);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -i, --ignore-case Ignore case when matching keywords (default)\n");
fprintf(stderr, " -h, --help Display this help message\n");
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
// Default to case-insensitive matching
int ignore_case = 0;
// Define long options
static struct option long_options[] = {
{"ignore-case", no_argument, NULL, 'i'},
{"help", no_argument, NULL, 'h'},
{0, 0, 0, 0}
};
int opt;
while ((opt = getopt_long(argc, argv, "ih", long_options, NULL)) != -1) {
switch (opt) {
case 'i':
ignore_case = 1;
break;
case 'h':
default:
print_usage(argv[0]);
break;
}
}
char line[MAX_LINE];
while (fgets(line, sizeof(line), stdin)) {
line[strcspn(line, "\n")] = 0;
char *space = strchr(line, ' ');
char token[MAX_LINE];
if (space) {
int len = space - line;
strncpy(token, line, len);
token[len] = '\0';
} else {
strcpy(token, line);
}
const char *color = "";
int count = sizeof(keyword_colors) / sizeof(keyword_colors[0]);
for (int i = 0; i < count; i++) {
// Use either case-sensitive or case-insensitive comparison based on the option
int match = ignore_case ?
strcasecmp(token, keyword_colors[i].keyword) == 0 :
strcmp(token, keyword_colors[i].keyword) == 0;
if (match) {
color = keyword_colors[i].color;
break;
}
}
if (color[0] != '\0')
printf("%s%s%s", color, token, COLOR_RESET);
else
printf("%s", token);
if (space)
printf("%s", space);
printf("\n");
}
return 0;
}

105
package/c/prettify/make.sh Normal file
View File

@@ -0,0 +1,105 @@
#!/bin/sh
# Usage: make.sh [build|check] [--norun] [--debug] [--color]
# Options:
# build Build the library and app (default if no mode is provided).
# watch Build the library and app and watch for changes.
# run Build and run the app.
# check Build tests; runs them unless --norun is specified.
# --norun (check only) Build tests but do not run them.
# --debug Build with -O0 (debug mode).
# --color Pass -fdiagnostics-color=always to compiler.
# help, --help Show this help message.
check_dependencies() {
for dep in cc ar pager; do
if ! command -v "$dep" >/dev/null 2>&1; then
echo "Error: Required dependency '$dep' not found." >&2
exit 1
fi
done
}
check_dependencies
print_help() {
cat <<EOF
Usage: $0 [build|check] [--norun] [--debug] [--color]
build Build the library and app (default).
watch Build the library and app and watch for changes.
run Build and run the app.
check Build tests; runs them unless --norun is specified.
--norun (check only) Build tests but do not run them.
--debug Build with debug flags (-O0).
--color Force colored compiler diagnostics.
help, --help Display this help message.
EOF
}
# Show help if requested
case "$1" in
help|--help)
print_help
exit 0
;;
esac
# Default flags
RUN_TESTS=1
OPTFLAGS="-O2"
CFLAGS="-Wall -Wextra -Werror -pedantic -fsanitize=address"
LDFLAGS="-lhectic"
STD_FLAGS="-std=c99"
COLOR_FLAG=""
MODE="${1:-build}"
shift
# Process options
while [ $# -gt 0 ]; do
case "$1" in
--norun)
RUN_TESTS=0
;;
--debug)
OPTFLAGS="-O0"
;;
--color)
COLOR_FLAG="-fdiagnostics-color=always"
;;
*)
echo "Unknown option: $1"
print_help
exit 1
;;
esac
shift
done
if [ -n "$COLOR_FLAG" ]; then
CFLAGS="$CFLAGS $COLOR_FLAG"
fi
build() {
mkdir -p target
echo "# Build app"
# shellcheck disable=SC2086
cc $CFLAGS $OPTFLAGS main.c $LDFLAGS -lhectic -o target/prettify
}
case "$MODE" in
watch)
find . -type d | nix run .#watch -- 'sh ./make.sh build && sh ./make.sh check' -i -p '*.c' -p '*.h' 2>&1
;;
build)
build
;;
run)
build && ./target/prettify
;;
check)
echo "No tests to run"
;;
*)
print_help
exit 1
;;
esac

View File

@@ -21,8 +21,9 @@
#define MAX_PATTERNS 32 #define MAX_PATTERNS 32
#define POLL_INTERVAL_MS 100 #define POLL_INTERVAL_MS 100
// Global flag to indicate if we're running in pager mode // Global flags
int pager_mode = 0; int pager_mode = 0;
int ignore_errors = 0;
FILE *output_stream = NULL; FILE *output_stream = NULL;
int running = 1; int running = 1;
@@ -37,11 +38,13 @@ void print_usage(const char *prog_name) {
fprintf(stderr, "Options:\n"); fprintf(stderr, "Options:\n");
fprintf(stderr, " -p <pattern> File pattern to watch (can be used multiple times)\n"); fprintf(stderr, " -p <pattern> File pattern to watch (can be used multiple times)\n");
fprintf(stderr, " -P Enable pager-friendly output (refresh mode)\n"); fprintf(stderr, " -P Enable pager-friendly output (refresh mode)\n");
fprintf(stderr, " -i, --ignore-errors Continue watching even when command returns non-zero\n");
fprintf(stderr, " -h Show this help message\n"); fprintf(stderr, " -h Show this help message\n");
fprintf(stderr, "Examples:\n"); fprintf(stderr, "Examples:\n");
fprintf(stderr, " %s 'make' -p '*.c' -p '*.h' ./src\n", prog_name); fprintf(stderr, " %s 'make' -p '*.c' -p '*.h' ./src\n", prog_name);
fprintf(stderr, " find . -type d | %s 'echo changed' -p '*.py'\n", prog_name); fprintf(stderr, " find . -type d | %s 'echo changed' -p '*.py'\n", prog_name);
fprintf(stderr, " %s -P 'make' -p '*.c' -p '*.h' ./src | less\n", prog_name); fprintf(stderr, " %s -P 'make' -p '*.c' -p '*.h' ./src | less\n", prog_name);
fprintf(stderr, " %s -i 'sh ./make.sh check' -p '*.c' -p '*.h' .\n", prog_name);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -174,10 +177,16 @@ int main(int argc, char *argv[]) {
char **patterns = malloc(MAX_PATTERNS * sizeof(char*)); char **patterns = malloc(MAX_PATTERNS * sizeof(char*));
int num_patterns = 0; int num_patterns = 0;
// Define long options
static struct option long_options[] = {
{"ignore-errors", no_argument, NULL, 'i'},
{0, 0, 0, 0}
};
optind = 2; optind = 2;
int opt; int opt;
while ((opt = getopt(argc, argv, "p:Ph")) != -1) { while ((opt = getopt_long(argc, argv, "p:Phi", long_options, NULL)) != -1) {
switch (opt) { switch (opt) {
case 'p': case 'p':
if (num_patterns < MAX_PATTERNS) { if (num_patterns < MAX_PATTERNS) {
@@ -190,6 +199,9 @@ int main(int argc, char *argv[]) {
case 'P': case 'P':
pager_mode = 1; pager_mode = 1;
break; break;
case 'i':
ignore_errors = 1;
break;
case 'h': case 'h':
print_usage(argv[0]); print_usage(argv[0]);
break; break;
@@ -439,8 +451,15 @@ int main(int argc, char *argv[]) {
if (any_changes) { if (any_changes) {
int res = system(command); int res = system(command);
if (res != 0) { if (res != 0) {
perror("system"); time_t current_time = time(NULL);
exit(EXIT_FAILURE); fprintf(output_stream, "Command failed at %s", ctime(&current_time));
fprintf(output_stream, "Command: %s (exit code: %d)\n", command, res);
fflush(output_stream);
if (!ignore_errors) {
fprintf(output_stream, "Exiting due to command failure. Use -i to ignore errors.\n");
running = 0;
}
} }
} }

View File

@@ -107,15 +107,7 @@ case "$MODE" in
fi fi
;; ;;
check) check)
mkdir -p target/test echo "No tests to run"
for test_file in test/*.c; do
exe="target/test/$(basename "${test_file%.c}")"
# shellcheck disable=SC2086
cc $CFLAGS $OPTFLAGS -pedantic "$test_file" $LDFLAGS -o "$exe"
if [ "$RUN_TESTS" -eq 1 ]; then
"$exe"
fi
done
;; ;;
*) *)
print_help print_help