From 6b06a0119445c6b004f4c3de7d61ad785c33a487 Mon Sep 17 00:00:00 2001 From: Josh Wolf Date: Mon, 18 Nov 2024 18:15:35 -0500 Subject: [PATCH] Add test(s) for bison (#34466) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 generated for as part of [expanding package test coverage](https://github.com/wolfi-dev/os/issues/13623) Signed-off-by: Josh Wolf --- bison.yaml | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/bison.yaml b/bison.yaml index 9b09bb7f5a2..b4ef62376ee 100644 --- a/bison.yaml +++ b/bison.yaml @@ -53,10 +53,93 @@ update: identifier: 193 test: + environment: + contents: + packages: + - build-base + - m4 + - gcc pipeline: - # AUTOGENERATED - - runs: | + - name: "Verify basic command availability" + runs: | bison --version yacc --version - bison --help - yacc --help + - name: "Test basic grammar parsing" + runs: | + cat > calc.y << 'EOF' + %{ + #include + void yyerror(const char *s) { fprintf(stderr, "%s\n", s); } + int yylex(void) { return 0; } + int main(void) { return 0; } + %} + %token NUMBER + %% + exp: NUMBER + %% + EOF + bison calc.y + - name: "Test yacc compatibility mode" + runs: | + cat > simple.y << 'EOF' + %token TOKEN + %% + start: TOKEN + %% + EOF + yacc simple.y + - name: "Verify different output formats" + runs: | + cat > test.y << 'EOF' + %token TEST + %% + rule: TEST + %% + EOF + bison -d test.y + test -f test.tab.h + test -f test.tab.c + - name: "Test verbose output generation" + runs: | + bison -v test.y + test -f test.output + - name: "Test XML output capability" + runs: | + bison -x test.y + test -f test.xml + - name: "Test error handling with invalid input" + runs: | + cat > invalid.y << 'EOF' + %invalid_directive + %% + invalid: grammar + %% + EOF + ! bison invalid.y + - name: "Test grammar with multiple rules" + runs: | + cat > multi.y << 'EOF' + %token NUM ID + %% + expr: NUM + | ID + | expr '+' expr + | expr '*' expr + ; + %% + EOF + bison multi.y + - name: "Test location tracking feature" + runs: | + cat > loc.y << 'EOF' + %locations + %token TOKEN + %% + start: TOKEN + %% + EOF + bison --locations loc.y + - name: "Verify report generation" + runs: | + bison --report=all test.y + test -f test.output