test: add end-to-end integration across dash/bash/zsh

This commit is contained in:
2026-08-29 01:10:28 -04:00
parent 22e22f2575
commit b94a540673
7 changed files with 573 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
# Makefile.in - integration-fixture template (plan todo 26).
#
# The substitution placeholders are filled by the generated ./configure
# (they must stay literal here - never expand them in this file). CC and
# CFLAGS come from the C language module's detection, LIBS from the feature
# probes' link flags (-lpthread/-lm), prefix from the --prefix default or
# override.
#
# NOTE: the substitution is LINE-BASED and runs on every line, comments
# included - so no comment may contain a placeholder-shaped token (the
# configure script would treat it as a variable to substitute).
#
# This file is NOT generated by stupidtools: the tool only substitutes
# placeholders into it (Makefile generation is out of v1 scope by design).
CC = @CC@
CFLAGS = @CFLAGS@ -std=c23 -Wall -Wextra -Wpedantic
LIBS = @LIBS@
prefix = @prefix@
all: demo
demo: main.c demo.c demo.h
$(CC) $(CFLAGS) main.c demo.c -o demo $(LIBS)
clean:
rm -f demo
+16
View File
@@ -0,0 +1,16 @@
/*
* demo.c - second translation unit of the integration fixture.
*
* Gives the fixture a real multi-file shape (the header demo.h is part of
* the deliverable "sources + headers"). Deliberately libm-free: the only
* libm dependency lives in main.c (sin), so a broken -lm accumulation is
* caught at LINK time there.
*/
#include "demo.h"
int
demo_compute(int x)
{
return x * 3 + 1;
}
+10
View File
@@ -0,0 +1,10 @@
/*
* demo.h - fixture header, included by main.c and demo.c.
*/
#ifndef HELLOTHREADS_DEMO_H
#define HELLOTHREADS_DEMO_H
int demo_compute(int x);
#endif /* HELLOTHREADS_DEMO_H */
+63
View File
@@ -0,0 +1,63 @@
/*
* main.c - integration-fixture entry point (plan todo 26).
*
* A REAL C23 program exercising both fixture features end to end:
* - pthread: pthread_create()/pthread_join() run a worker thread (guarded
* by the HAVE_PTHREAD define the generated config.h wrote), printing a
* grep-able marker the runner asserts on;
* - math: sin(0.5) from libm, printed with a fixed format the runner
* greps (the link would fail without -lm, so a successful run proves
* the LIBS accumulation reached the Makefile).
*
* _POSIX_C_SOURCE must be defined BEFORE the first include: under strict
* -std=c23 glibc sets __STRICT_ANSI__ and hides pthread_create's
* declaration, which C23 turns into an implicit-declaration ERROR
* (the same trap recorded for src/ in the project learnings).
*/
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#include "config.h"
#include "demo.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_PTHREAD
#include <pthread.h>
static void *
worker(void *arg)
{
(void)arg;
printf("worker thread ran\n");
return NULL;
}
#endif
int
main(void)
{
double s = sin(0.5);
printf("hellothreads demo: sin(0.5) = %.4f\n", s);
printf("demo_compute(2) = %d\n", demo_compute(2));
#ifdef HAVE_PTHREAD
{
pthread_t t;
if (pthread_create(&t, NULL, worker, NULL) != 0) {
fprintf(stderr, "pthread_create failed\n");
return EXIT_FAILURE;
}
if (pthread_join(t, NULL) != 0) {
fprintf(stderr, "pthread_join failed\n");
return EXIT_FAILURE;
}
}
#endif
return EXIT_SUCCESS;
}
@@ -0,0 +1,37 @@
/* project-fail.kdl - the FAILURE variant of project.kdl (plan todo 26).
*
* Same shape as project.kdl, but the pthread feature is replaced by a
* feature checking a header that does not exist on any system:
*
* feature "nope" { header "nope_missing_xyz.h" }
*
* The generated ./configure must handle the failed probe CLEANLY under
* every shell in the matrix: the failure is recorded (have_nope=no), the
* check is named in config.log (the compiler's diagnostic), config.h gets
* NO HAVE_NOPE define, and no shell reports a syntax error. A healthy
* second feature ("posix", unistd.h) proves configure continues after a
* failed check and the healthy feature still resolves.
*
* NOTE (deviation, tracked in .omo/notepads/stupidtools/issues.md): the
* v1 generator (todos 16/17, frozen to todo 26) follows autoconf
* semantics - a failed OPTIONAL check records have_<name>=no and
* configure still exits 0; it does not abort. The plan/todo text expected
* rc!=0 here. run.sh asserts the generator's REAL contract and exercises
* the genuinely-non-zero configure-error path via an unrecognized option.
*/
project "hellothreads-fail" version "1.0.0"
feature "nope" {
header "nope_missing_xyz.h"
}
feature "posix" {
header "unistd.h"
}
target "default" {
src "main.c"
feature "nope"
feature "posix"
}
+39
View File
@@ -0,0 +1,39 @@
/* project.kdl - integration-fixture build file (plan todo 26).
*
* A small but REAL C project exercising the DSL the way a user would:
* - feature "pthread": a header check (pthread.h) AND a library check
* (pthread -> -lpthread), like the classic autoconf AC_CHECK_HEADER +
* AC_CHECK_LIB pair;
* - feature "math": an optional library check (m -> -lm). Not strictly
* required by every build (an option maps to --enable-math/--disable
* --math), but present so the generated Makefile accumulates -lm
* when it resolves;
* - target "default": the real source list of the fixture (descriptive
* in v1 - the generated configure substitutes @VAR@ into Makefile.in,
* it does not generate Makefiles);
* - option "debug": an option node, proving the --enable-debug /
* --disable-debug surface shows up in the generated --help.
*
* DSL grammar (src/kdl/schema.h): `project` first, then targets/features/
* options; feature children are checks (header/library/... from the 8
* registry kinds). */
project "hellothreads" version "1.0.0"
feature "pthread" {
header "pthread.h"
library "pthread"
}
feature "math" {
library "m"
}
target "default" {
src "main.c"
src "demo.c"
feature "pthread"
feature "math"
}
option "debug" default=#false