2
0

Makefile 3.5 KB

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