diff --git a/parser-test/Makefile b/parser-test/Makefile deleted file mode 100644 index 72953fa3e..000000000 --- a/parser-test/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Standalone build for the cmd-parse.y AST parser. -# -# Compiles only ../cmd-parse.y + ../tmux-parser.h against the local stub tmux.h -# and tiny helper stubs. The rest of tmux is not needed. - -YACC ?= bison -y -CC ?= cc - -CFLAGS += -D_GNU_SOURCE -I. -I.. -g -Wall - -OBJS = y.tab.o main.o xstubs.o - -parsetest: $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) - -y.tab.c: ../cmd-parse.y - $(YACC) -d ../cmd-parse.y - -y.tab.o: y.tab.c - $(CC) $(CFLAGS) -c -o $@ y.tab.c - -main.o: main.c tmux.h - $(CC) $(CFLAGS) -c -o $@ main.c - -xstubs.o: xstubs.c tmux.h - $(CC) $(CFLAGS) -c -o $@ xstubs.c - -clean: - rm -f parsetest y.tab.c y.tab.h $(OBJS) - -.PHONY: clean diff --git a/parser-test/main.c b/parser-test/main.c deleted file mode 100644 index 9ca92dd0a..000000000 --- a/parser-test/main.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Standalone driver for the cmd-parse.y AST parser. Reads a config/command - * file (argument, or stdin) and prints both forms: the debug AST dump via - * cmd_parse_log (to stderr) and the normalized form via cmd_parse_print (to - * stdout). - * - * Usage: parsetest [file] - */ - -#include - -#include "tmux.h" -#include "tmux-parser.h" - -int -main(int argc, char **argv) -{ - struct cmd_parse_input pi; - struct cmd_parse_tree *tree; - FILE *f = stdin; - char *cause = NULL, *out; - - /* As tmux does at startup, so \u/\U escapes can be encoded. */ - setlocale(LC_CTYPE, ""); - - memset(&pi, 0, sizeof pi); - pi.line = 1; - if (getenv("ONEGROUP") != NULL) - pi.flags |= CMD_PARSE_ONEGROUP; - if (argc > 1) { - pi.file = argv[1]; - if ((f = fopen(argv[1], "r")) == NULL) { - perror(argv[1]); - return (1); - } - } - - tree = cmd_parse_from_file(f, &pi, &cause); - if (f != stdin) - fclose(f); - - if (tree == NULL) { - fprintf(stderr, "parse error: %s\n", - cause != NULL ? cause : "unknown"); - free(cause); - return (1); - } - - fprintf(stdout, "=== AST (stderr) ===\n"); - fflush(stdout); - cmd_parse_log(tree); - - out = cmd_parse_print(tree); - fprintf(stdout, "=== NORMALIZED ===\n%s\n", out); - free(out); - - cmd_parse_free(tree); - return (0); -} diff --git a/parser-test/test-configs/bind-key-body-verify.tmux b/parser-test/test-configs/bind-key-body-verify.tmux deleted file mode 100644 index da2b458ce..000000000 --- a/parser-test/test-configs/bind-key-body-verify.tmux +++ /dev/null @@ -1,9 +0,0 @@ -set -g status off -bind-key F1 { - display-message "parser bind body: F1" - run-shell "echo F1-FIRED >> /tmp/claude-1000/-home-nicholas-tmux-claude/9fb594c3-5fb9-41b2-8a5a-8d3d0b39b009/scratchpad/bindresult.txt" -} -bind-key F2 { - run-shell "echo F2-FIRST >> /tmp/claude-1000/-home-nicholas-tmux-claude/9fb594c3-5fb9-41b2-8a5a-8d3d0b39b009/scratchpad/bindresult.txt" - run-shell "echo F2-SECOND >> /tmp/claude-1000/-home-nicholas-tmux-claude/9fb594c3-5fb9-41b2-8a5a-8d3d0b39b009/scratchpad/bindresult.txt" -} diff --git a/parser-test/test-configs/bind-key-body.tmux b/parser-test/test-configs/bind-key-body.tmux deleted file mode 100644 index 038f4b640..000000000 --- a/parser-test/test-configs/bind-key-body.tmux +++ /dev/null @@ -1,5 +0,0 @@ -bind-key F1 { display-message "parser bind body: F1" } -bind-key F2 { - display-message "parser bind body: first" - display-message "parser bind body: second" -} diff --git a/parser-test/test-configs/command-body-unsupported.tmux b/parser-test/test-configs/command-body-unsupported.tmux deleted file mode 100644 index 7a89a0200..000000000 --- a/parser-test/test-configs/command-body-unsupported.tmux +++ /dev/null @@ -1,3 +0,0 @@ -# Command body unsupported checkpoint. -# Expected at this stage: should parse, then fatal/XXX when invocation reaches ARGS_COMMANDS. -bind-key F1 { display-message "parser command body" } diff --git a/parser-test/test-configs/env-tilde.tmux b/parser-test/test-configs/env-tilde.tmux deleted file mode 100644 index 61e36148d..000000000 --- a/parser-test/test-configs/env-tilde.tmux +++ /dev/null @@ -1,2 +0,0 @@ -display-message "HOME=$HOME" -display-message ~ diff --git a/parser-test/test-configs/failure-sequence.tmux b/parser-test/test-configs/failure-sequence.tmux deleted file mode 100644 index 60138e88d..000000000 --- a/parser-test/test-configs/failure-sequence.tmux +++ /dev/null @@ -1,5 +0,0 @@ -# Failure scope test. -# Expected with sequence skipping: bad command fails, following command in same sequence is skipped, -# then next top-level sequence still runs. -display-message "parser failure: before bad command" ; no-such-tmux-command ; display-message "parser failure: should be skipped" -display-message "parser failure: next sequence should still run" diff --git a/parser-test/test-configs/if-else-elif.tmux b/parser-test/test-configs/if-else-elif.tmux deleted file mode 100644 index 4af18cbfd..000000000 --- a/parser-test/test-configs/if-else-elif.tmux +++ /dev/null @@ -1,10 +0,0 @@ -# %if/%elif/%else. -# Expected: elif branch is selected. -%if 0 -display-message "parser elif: selected if branch - wrong" -%elif 1 -display-message "parser elif: selected elif branch" -%else -display-message "parser elif: selected else branch - wrong" -%endif -display-message "parser elif: after endif" diff --git a/parser-test/test-configs/if-true.tmux b/parser-test/test-configs/if-true.tmux deleted file mode 100644 index a714cc45c..000000000 --- a/parser-test/test-configs/if-true.tmux +++ /dev/null @@ -1,8 +0,0 @@ -# %if true branch. -# Expected: first branch is selected. -%if 1 -display-message "parser if true: selected if branch" -%else -display-message "parser if true: selected else branch - wrong" -%endif -display-message "parser if true: after endif" diff --git a/parser-test/test-configs/inline-if.tmux b/parser-test/test-configs/inline-if.tmux deleted file mode 100644 index 61d3aecae..000000000 --- a/parser-test/test-configs/inline-if.tmux +++ /dev/null @@ -1,3 +0,0 @@ -# Inline %if form. -# Expected: inline true branch selected, then following command in same sequence is processed. -display-message "parser inline if: before" ; %if 1 display-message "parser inline if: branch" %endif ; display-message "parser inline if: after" diff --git a/parser-test/test-configs/semicolon.tmux b/parser-test/test-configs/semicolon.tmux deleted file mode 100644 index faf198996..000000000 --- a/parser-test/test-configs/semicolon.tmux +++ /dev/null @@ -1,3 +0,0 @@ -# Semicolon sequence. -# Expected: one top-level sequence containing three commands. -set -g status on ; set -g message-style fg=yellow ; display-message "parser semicolon sequence" diff --git a/parser-test/test-configs/simple.tmux b/parser-test/test-configs/simple.tmux deleted file mode 100644 index fce14a2ca..000000000 --- a/parser-test/test-configs/simple.tmux +++ /dev/null @@ -1,5 +0,0 @@ -# Simple straight-line commands. -# Expected: all commands parse and run in order. -set -g status off -set -g message-style fg=green -display-message "parser simple: status=#{status}" diff --git a/parser-test/tmux.h b/parser-test/tmux.h deleted file mode 100644 index ba98efe9d..000000000 --- a/parser-test/tmux.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Stub tmux.h for the standalone cmd-parse.y test harness. - * - * This is NOT the real tmux.h. It provides just enough for cmd-parse.y to - * compile and link on its own: the queue macros, the allocation/logging - * helpers it calls, and the small part of struct cmd_parse_input it touches. - * It is found ahead of the real tmux.h via the harness include path. - */ - -#ifndef TMUX_TEST_STUB_H -#define TMUX_TEST_STUB_H - -#include - -#include -#include -#include -#include -#include -#include - -#include "compat/queue.h" - -#ifndef __dead -#define __dead __attribute__((__noreturn__)) -#endif -#ifndef __unused -#define __unused __attribute__((__unused__)) -#endif -#ifndef printflike -#define printflike(a, b) __attribute__((format(printf, a, b))) -#endif - -/* Allocation helpers (implemented in xstubs.c). */ -void *xmalloc(size_t); -void *xcalloc(size_t, size_t); -void *xrealloc(void *, size_t); -char *xstrdup(const char *); -char *xstrndup(const char *, size_t); -int xasprintf(char **, const char *, ...) printflike(2, 3); -int xvasprintf(char **, const char *, va_list); - -/* Logging and fatal errors (implemented in xstubs.c). */ -void log_debug(const char *, ...) printflike(1, 2); -__dead void fatal(const char *, ...) printflike(1, 2); -__dead void fatalx(const char *, ...) printflike(1, 2); - -#endif /* TMUX_TEST_STUB_H */ diff --git a/parser-test/xstubs.c b/parser-test/xstubs.c deleted file mode 100644 index 2866a2664..000000000 --- a/parser-test/xstubs.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Minimal implementations of the helpers cmd-parse.y links against. */ - -#include "tmux.h" - -#include - -void * -xmalloc(size_t size) -{ - void *ptr; - - if (size == 0) - size = 1; - if ((ptr = malloc(size)) == NULL) - fatalx("xmalloc"); - return (ptr); -} - -void * -xcalloc(size_t nmemb, size_t size) -{ - void *ptr; - - if (nmemb == 0 || size == 0) - nmemb = size = 1; - if ((ptr = calloc(nmemb, size)) == NULL) - fatalx("xcalloc"); - return (ptr); -} - -void * -xrealloc(void *oldptr, size_t newsize) -{ - void *ptr; - - if (newsize == 0) - newsize = 1; - if ((ptr = realloc(oldptr, newsize)) == NULL) - fatalx("xrealloc"); - return (ptr); -} - -char * -xstrdup(const char *s) -{ - char *ptr; - - if ((ptr = strdup(s)) == NULL) - fatalx("xstrdup"); - return (ptr); -} - -char * -xstrndup(const char *s, size_t maxlen) -{ - char *ptr; - - if ((ptr = strndup(s, maxlen)) == NULL) - fatalx("xstrndup"); - return (ptr); -} - -int -xvasprintf(char **ret, const char *fmt, va_list ap) -{ - int i; - - if ((i = vasprintf(ret, fmt, ap)) < 0) - fatalx("xvasprintf"); - return (i); -} - -int -xasprintf(char **ret, const char *fmt, ...) -{ - va_list ap; - int i; - - va_start(ap, fmt); - i = xvasprintf(ret, fmt, ap); - va_end(ap); - return (i); -} - -void -log_debug(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fputc('\n', stderr); -} - -__dead void -fatal(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, ": %s\n", strerror(errno)); - exit(1); -} - -__dead void -fatalx(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fputc('\n', stderr); - exit(1); -}