@@ -7,28 +7,55 @@ When submitting code, please make efforts to follow existing conventions and
77style in order to keep the code as readable as possible. Please also make sure
88all tests pass by running ` mage test:all ` , and format your code with ` go fmt ` .
99
10+ ## Go Toolchain Setup
11+
12+ This project requires the Go version specified in ` go.mod ` . If the default ` go `
13+ on PATH is older, builds will fail with a version mismatch error.
14+
15+ ** Claude Code (cloud environment):** Multiple Go versions are installed
16+ side-by-side under ` /usr/local/ ` . The default ` /usr/local/go/ ` may be older
17+ than what this project requires. Check for a matching version (e.g.
18+ ` /usr/local/go<VERSION>/bin/go ` ) and prepend it to your PATH:
19+
20+ ``` bash
21+ # Find available Go versions
22+ ls /usr/local/go* /bin/go
23+
24+ # Use the version that matches go.mod (check with: grep '^go ' go.mod)
25+ export PATH=" /usr/local/go<VERSION>/bin:$PATH "
26+ go version
27+ ```
28+
29+ Mage is available as a Go tool dependency (no separate install needed):
30+
31+ ``` bash
32+ go tool mage -l # list all targets
33+ ```
34+
1035## Build & Test Commands
1136
12- This project uses [ mage] ( https://magefile.org ) as the build system (defined in ` magefile.go ` ):
37+ This project uses [ mage] ( https://magefile.org ) as the build system (defined in ` magefile.go ` ).
38+ Invoke it via ` go tool mage ` (not a standalone ` mage ` binary):
1339
1440``` bash
15- mage go:build # Build binary
16- mage go:lint # Run golangci-lint (config: .golangci.yml)
17- mage test:all # Unit + integration tests with merged coverage
18- mage test:unit # Go unit tests only
19- mage test:integration # Python integration tests only
20- mage test:docker # Full suite in Docker (includes PKCS#11/SoftHSM)
21- mage test:keys # Generate test certificates in test-keys/
22- mage docker:build # Build Docker images
23- mage -l # List all available targets
41+ go tool mage go:build # Build binary
42+ go tool mage go:lint # Run golangci-lint (config: .golangci.yml)
43+ go tool mage test:all # Unit + integration tests with merged coverage
44+ go tool mage test:unit # Go unit tests only
45+ go tool mage test:integration # Python integration tests only
46+ go tool mage test:docker # Full suite in Docker (includes PKCS#11/SoftHSM)
47+ go tool mage test:keys # Generate test certificates in test-keys/
48+ go tool mage docker:build # Build Docker images
49+ go tool mage -l # List all available targets
2450```
2551
2652### Running a Single Test
2753
2854``` bash
29- go test -v -run TestName ./... # Single Go unit test
30- go test -v ./auth/... # All tests in a package
31- cd tests && python3 test-name.py # Single integration test
55+ go test -v -run TestName ./... # Single Go unit test
56+ go test -v ./auth/... # All tests in a package
57+ go tool mage test:single test-server-pem-rsa # Single integration test (via mage)
58+ cd tests && python3 test-server-pem-rsa.py # Single integration test (directly)
3259```
3360
3461### Linting
@@ -52,14 +79,30 @@ run checks on a live instance. If you are adding new features or changing
5279existing behavior, please add/update the integration tests in the ` tests/ `
5380directory accordingly. The tests use the ` tests/common.py ` helper module.
5481
55- Integration tests run in parallel by default (up to ` NumCPU ` , capped at 16 by default).
56- Set ` GHOSTUNNEL_TEST_PARALLEL ` to control the number of concurrent tests (may exceed the default cap):
82+ ### Prerequisites
83+
84+ 1 . ** Go** at the version specified in ` go.mod ` on PATH (see "Go Toolchain Setup" above).
85+ 2 . ** Python 3** with packages used by the test harness (typically already available).
86+ 3 . ** Test certificates** must be generated before the first run:
87+
88+ ``` bash
89+ go tool mage test:keys # generates certs in test-keys/
90+ ```
91+
92+ ### Running Integration Tests
5793
5894``` bash
59- GHOSTUNNEL_TEST_PARALLEL=4 mage test:integration
95+ go tool mage test:integration # all integration tests
96+ go tool mage test:single test-server-pem-rsa # single test by name
97+ GHOSTUNNEL_TEST_PARALLEL=4 go tool mage test:integration # control parallelism
6098```
6199
62- Test certificates are generated in ` test-keys/ ` via ` mage test:keys ` .
100+ Integration tests run in parallel by default (up to ` NumCPU ` , capped at 16).
101+ Set ` GHOSTUNNEL_TEST_PARALLEL ` to control the number of concurrent tests (may exceed the default cap).
102+
103+ The integration test runner first builds a coverage-instrumented test binary
104+ (` go test -c ` ), then runs each ` tests/test-*.py ` script against that binary.
105+ Each Python test starts a ghostunnel process, exercises it, and verifies behavior.
63106
64107## Architecture Overview
65108
0 commit comments