Makefile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. .PHONY: build test test-v test-cover bench clean fmt lint sqllogictest sqllogictest-basic sqllogictest-download build-sqllogictest
  2. # Build the project
  3. build:
  4. go build -o ./bin/pizzasql ./main.go
  5. build-linux-amd64:
  6. GOOS=linux GOARCH=amd64 go build -o ./bin/pizzasql-linux-amd64 ./main.go
  7. # Run all tests
  8. test:
  9. go test ./...
  10. # Run tests with verbose output
  11. test-v:
  12. go test -v ./...
  13. # Run tests with coverage
  14. test-cover:
  15. go test -coverprofile=coverage.out ./...
  16. go tool cover -html=coverage.out -o coverage.html
  17. @echo "Coverage report: coverage.html"
  18. # Run benchmarks
  19. bench:
  20. go test -bench=. -benchmem ./...
  21. # Run lexer tests only
  22. test-lexer:
  23. go test -v ./pkg/lexer/...
  24. # Run parser tests only
  25. test-parser:
  26. go test -v ./pkg/parser/...
  27. # Format code
  28. fmt:
  29. go fmt ./...
  30. # Run linter (requires golangci-lint)
  31. lint:
  32. golangci-lint run
  33. # Clean build artifacts
  34. clean:
  35. rm -f pizzasql coverage.out coverage.html
  36. # Run tests with race detection
  37. test-race:
  38. go test -race ./...
  39. # Quick test for development
  40. quick:
  41. go test -short ./...
  42. # ── sqllogictest ──────────────────────────────────────────────────────────────
  43. # Run the sqllogictest suite against a running PizzaSQL server (default: localhost:8080).
  44. # Set URL= to point at a different server, e.g. make sqllogictest URL=http://host:9090
  45. sqllogictest:
  46. go run ./cmd/sqllogictest -url $(or $(URL),http://localhost:8080) -dir testdata/sqllogictest -log sqllogictest-failures.log
  47. # Run only the built-in smoke test.
  48. sqllogictest-basic:
  49. go run ./cmd/sqllogictest -url $(or $(URL),http://localhost:8080) -file testdata/sqllogictest/basic.test
  50. # Download the official SQLite sqllogictest corpus into testdata/sqllogictest/.
  51. # Requires curl and tar. Files are not committed to the repo.
  52. sqllogictest-download:
  53. @echo "Downloading SQLite sqllogictest corpus..."
  54. mkdir -p testdata/sqllogictest
  55. mkdir -p /tmp/sqllogictest-dl
  56. curl -fsSL https://github.com/gregrahn/sqllogictest/archive/refs/heads/master.tar.gz \
  57. | tar xz -C /tmp/sqllogictest-dl
  58. find /tmp/sqllogictest-dl -name '*.test' | while read f; do \
  59. rel=$$(echo "$$f" | sed 's|.*/test/||'); \
  60. dir=testdata/sqllogictest/$$(dirname "$$rel"); \
  61. mkdir -p "$$dir"; \
  62. cp "$$f" "$$dir/"; \
  63. done
  64. rm -rf /tmp/sqllogictest-dl
  65. @echo "Done. $$(find testdata/sqllogictest -name '*.test' | wc -l | tr -d ' ') test files in testdata/sqllogictest/"
  66. # Build the sqllogictest runner binary.
  67. build-sqllogictest:
  68. go build -o ./bin/sqllogictest ./cmd/sqllogictest