Artifact 3e14dd83f4a08c6ca5ab21416348e411c25debd346f2fc820c490a8a8941fc21:
- File
src/need.h
— part of check-in
[3598f9d78d]
at
2026-11-14 13:15:53
on branch trunk
— Phase 8a: needs are checked, listed, and shown until they are done
A need is a step a harness must do for itself, such as registering a slot in its own settings. suit never edits those settings; it says what is needed and can tell when it has been done.
The done test has two forms and nothing else: PATH exists, and PATH contains "TEXT". suit needs lists every need as done, not done or cannot tell, and changes nothing. suit need HARNESS NAME prints the prompt's exact bytes so it can be handed to the harness.
After each apply the attention file holds one item for each need not done and none for those that are. Other kinds of item are left alone and keep their order, and nothing is written when nothing changed. If that update fails, apply writes no stamp, so the next run tries again. A bad need stops apply before it places anything. suit off removes the items.
suit-run is untouched and the speed budget still passes.
An eighth fuzz target covers the done-test parser.
1355 unit checks, 479 shell cases, 669 store cases, 745 placement cases and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (34 minutes). 100% coverage in all 24 source files. No suite has fewer cases than at the last check-in. (user: dmestas, size: 1483) [annotate] [blame] [check-ins using]
#ifndef SUIT_NEED_H #define SUIT_NEED_H #include <stdbool.h> #include <stddef.h> // The test a need carries in its `done` text. Two forms and nothing else: // PATH exists // PATH contains "TEXT" // PATH is one word; a leading ~ is the home folder; it must then be absolute. // TEXT is everything between the first quote after "contains " and the last // quote on the line, and is not empty. constexpr size_t DONE_PATH_MAX = 4096; constexpr size_t DONE_FILE_MAX = 4 * 1048576; // a file over this is not searched constexpr size_t DONE_WHY_MAX = 256; typedef enum { DONE_EXISTS, DONE_CONTAINS } DoneKind; // TEXT points into the string that was parsed, which must outlive the test. typedef struct { DoneKind kind; char path[DONE_PATH_MAX]; const char *text; size_t text_len; } DoneTest; typedef enum { NEED_DONE, NEED_NOT_DONE, NEED_UNKNOWN } NeedState; // Read the test in S, with HOME the home folder. False if it is not one of // the two forms, with WHY (CAP bytes) saying what is wrong. [[nodiscard]] bool done_parse(DoneTest *t, const char *home, const char *s, char *why, size_t cap); // Whether the test holds. A missing file is not done. A file that cannot be // read, or is not a regular file, or is over DONE_FILE_MAX, is NEED_UNKNOWN, // and WHY says why. NeedState done_eval(const DoneTest *t, char *why, size_t cap); // Whether P is a path inside the store: not empty, relative, with no ".." part. bool need_prompt_ok(const char *p); #endif