{
    "sourceFile": "tests/clap_noun_verb_validation.sh",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 0,
            "patches": [
                {
                    "date": 1762978965525,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                }
            ],
            "date": 1762978965525,
            "name": "Commit-0",
            "content": "#!/bin/bash\n# Standalone validation script for clap-noun-verb v3.4.0 integration\n# Tests CLI auto-discovery, template generation, and E2E workflow\n\n# Don't exit on first failure - we want to run all tests\nset +e\n\nGGEN=\"./target/debug/ggen\"\nTEST_DIR=$(mktemp -d)\nPASSED=0\nFAILED=0\n\nfunction test_passed() {\n    echo \"✅ PASSED: $1\"\n    ((PASSED++))\n}\n\nfunction test_failed() {\n    echo \"❌ FAILED: $1\"\n    ((FAILED++))\n}\n\nfunction cleanup() {\n    rm -rf \"$TEST_DIR\"\n}\n\ntrap cleanup EXIT\n\necho \"=== CLAP-NOUN-VERB v3.4.0 INTEGRATION TESTS ===\"\necho \"Test directory: $TEST_DIR\"\necho \"\"\n\n# TEST SUITE 1: CLI AUTO-DISCOVERY\necho \"=== TEST SUITE 1: CLI AUTO-DISCOVERY ===\"\n\n# Test 1: ggen --help shows template noun\nif $GGEN --help | grep -q \"template\"; then\n    test_passed \"ggen --help shows template noun\"\nelse\n    test_failed \"ggen --help shows template noun\"\nfi\n\n# Test 2: template --help shows all verbs\nif $GGEN template --help | grep -q \"list\" && $GGEN template --help | grep -q \"new\" && $GGEN template --help | grep -q \"generate\"; then\n    test_passed \"template --help shows all verbs\"\nelse\n    test_failed \"template --help shows all verbs\"\nfi\n\n# Test 3: template list command exists in help\nif $GGEN template --help | grep -q \"list\"; then\n    test_passed \"template list command exists\"\nelse\n    test_failed \"template list command exists\"\nfi\n\n# Test 4: template lint --help shows arguments\nif $GGEN template lint --help | grep -q -E \"(path|PATH|template)\"; then\n    test_passed \"template lint --help shows arguments\"\nelse\n    test_failed \"template lint --help shows arguments\"\nfi\n\n# Test 5: Invalid commands return proper errors\nif $GGEN invalid-noun 2>&1 | grep -q -E \"(error|invalid|unrecognized)\"; then\n    test_passed \"Invalid noun returns error\"\nelse\n    test_failed \"Invalid noun returns error\"\nfi\n\n# Test 6: Invalid verbs return errors\nif $GGEN template invalid-verb 2>&1 | grep -q -E \"(error|invalid|unrecognized)\"; then\n    test_passed \"Invalid verb returns error\"\nelse\n    test_failed \"Invalid verb returns error\"\nfi\n\n# Test 7: Version flag works\nif $GGEN --version | grep -q \"ggen\"; then\n    test_passed \"CLI version flag works\"\nelse\n    test_failed \"CLI version flag works\"\nfi\n\necho \"\"\necho \"=== TEST SUITE 2: TEMPLATE-DRIVEN PROJECT GENERATION ===\"\n\n# Create test TTL specification\nTTL_FILE=\"$TEST_DIR/cli-spec.ttl\"\ncat > \"$TTL_FILE\" << 'EOF'\n@prefix cli: <http://example.org/cli#> .\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\ncli:MyCLI a cli:Application ;\n    rdfs:label \"MyCLI\" ;\n    cli:hasNoun cli:UserNoun, cli:ProjectNoun .\n\ncli:UserNoun a cli:Noun ;\n    rdfs:label \"user\" ;\n    cli:hasVerb cli:ListVerb, cli:CreateVerb .\nEOF\n\n# Test 8: TTL file created with valid RDF\nif [ -f \"$TTL_FILE\" ] && grep -q \"cli:Application\" \"$TTL_FILE\"; then\n    test_passed \"RDF CLI definition loads\"\nelse\n    test_failed \"RDF CLI definition loads\"\nfi\n\n# Create CLI tree spec\nTREE_SPEC=\"$TEST_DIR/cli-tree.yaml\"\ncat > \"$TREE_SPEC\" << 'EOF'\nfiles:\n  - path: \"Cargo.toml\"\n    content: |\n      [package]\n      name = \"testcli\"\n      version = \"0.1.0\"\n      edition = \"2021\"\n\n      [dependencies]\n      clap = { version = \"4.5\", features = [\"derive\"] }\n      clap-noun-verb = \"3.4.0\"\n  - path: \"src/main.rs\"\n    content: |\n      use clap::Parser;\n\n      #[derive(Parser)]\n      struct Cli {\n          #[command(subcommand)]\n          command: Commands,\n      }\n\n      #[derive(clap::Subcommand)]\n      enum Commands {\n          User,\n          Project,\n      }\n\n      fn main() {\n          let _cli = Cli::parse();\n          println!(\"CLI executed\");\n      }\nEOF\n\nOUTPUT_DIR=\"$TEST_DIR/generated\"\nmkdir -p \"$OUTPUT_DIR\"\n\n# Test 9: Generate project from tree spec\nif $GGEN template generate-tree --template \"$TREE_SPEC\" --output \"$OUTPUT_DIR\"; then\n    test_passed \"Template generates from tree spec\"\nelse\n    test_failed \"Template generates from tree spec\"\nfi\n\n# Test 10: Generated project structure valid\nif [ -f \"$OUTPUT_DIR/Cargo.toml\" ] && [ -f \"$OUTPUT_DIR/src/main.rs\" ]; then\n    test_passed \"Generated project structure valid\"\nelse\n    test_failed \"Generated project structure valid\"\nfi\n\n# Test 11: Cargo.toml has clap dependency\nif grep -q \"clap\" \"$OUTPUT_DIR/Cargo.toml\"; then\n    test_passed \"Generated Cargo.toml has clap dependency\"\nelse\n    test_failed \"Generated Cargo.toml has clap dependency\"\nfi\n\n# Test 12: Generated code matches spec\nif grep -q \"User\" \"$OUTPUT_DIR/src/main.rs\" && grep -q \"Project\" \"$OUTPUT_DIR/src/main.rs\"; then\n    test_passed \"Generated CLI code matches RDF spec\"\nelse\n    test_failed \"Generated CLI code matches RDF spec\"\nfi\n\necho \"\"\necho \"=== TEST SUITE 3: END-TO-END WORKFLOW ===\"\n\n# Test 13: Cargo.toml is valid TOML\nif command -v toml-cli &> /dev/null; then\n    if toml-cli get \"$OUTPUT_DIR/Cargo.toml\" \"package.name\" &> /dev/null; then\n        test_passed \"Generated Cargo.toml is valid TOML\"\n    else\n        test_failed \"Generated Cargo.toml is valid TOML\"\n    fi\nelse\n    # Fallback: check basic structure\n    if grep -q \"\\[package\\]\" \"$OUTPUT_DIR/Cargo.toml\" && grep -q \"\\[dependencies\\]\" \"$OUTPUT_DIR/Cargo.toml\"; then\n        test_passed \"Generated Cargo.toml has valid structure\"\n    else\n        test_failed \"Generated Cargo.toml is valid TOML\"\n    fi\nfi\n\n# Test 14: main.rs has main function\nif grep -q \"fn main()\" \"$OUTPUT_DIR/src/main.rs\"; then\n    test_passed \"Generated main.rs has main function\"\nelse\n    test_failed \"Generated main.rs has main function\"\nfi\n\n# Test 15: Code has clap attributes\nif grep -q \"Parser\" \"$OUTPUT_DIR/src/main.rs\" && grep -q \"Subcommand\" \"$OUTPUT_DIR/src/main.rs\"; then\n    test_passed \"Generated code has clap attributes\"\nelse\n    test_failed \"Generated code has clap attributes\"\nfi\n\necho \"\"\necho \"=== PERFORMANCE TESTS ===\"\n\n# Test 16: Generation performance < 2 seconds\nSTART_TIME=$(date +%s)\nOUTPUT_PERF=\"$TEST_DIR/perf\"\nmkdir -p \"$OUTPUT_PERF\"\n$GGEN template generate-tree --template \"$TREE_SPEC\" --output \"$OUTPUT_PERF\"\nEND_TIME=$(date +%s)\nDURATION=$((END_TIME - START_TIME))\n\nif [ \"$DURATION\" -lt 2 ]; then\n    test_passed \"Template generation under 2 seconds ($DURATION s)\"\nelse\n    test_failed \"Template generation under 2 seconds (took $DURATION s)\"\nfi\n\n# Test 17: Help command is fast\nSTART_TIME=$(date +%s)\n$GGEN template --help > /dev/null\nEND_TIME=$(date +%s)\nHELP_DURATION=$((END_TIME - START_TIME))\n\nif [ \"$HELP_DURATION\" -lt 2 ]; then\n    test_passed \"Help command is fast ($HELP_DURATION s)\"\nelse\n    test_failed \"Help command is fast (took $HELP_DURATION s)\"\nfi\n\necho \"\"\necho \"=== TEST SUMMARY ===\"\necho \"Passed: $PASSED\"\necho \"Failed: $FAILED\"\necho \"Total:  $((PASSED + FAILED))\"\n\nif [ \"$FAILED\" -eq 0 ]; then\n    echo \"✅ All tests passed!\"\n    exit 0\nelse\n    echo \"❌ Some tests failed\"\n    exit 1\nfi\n"
        }
    ]
}