Makefile 3.0 KB

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