You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,11 +38,14 @@ The build script (`build.ts`) injects the git commit SHA, target OS and architec
38
38
## Running tests
39
39
40
40
```bash
41
-
bun test# run the whole test suite
41
+
bun test# run the whole TypeScript test suite
42
42
bun test --watch # re-run on file changes (development)
43
+
bun run test:bats # run the shell-integration tests for install.sh (requires bats-core)
43
44
```
44
45
45
-
All tests use Bun's built-in test runner (`@jest/globals`-compatible API: `describe`, `it`, `expect`). No additional testing library is needed. The setup file is `src/test-setup.ts` (referenced in `bunfig.toml`).
46
+
All TypeScript tests use Bun's built-in test runner (`@jest/globals`-compatible API: `describe`, `it`, `expect`). No additional testing library is needed. The setup file is `src/test-setup.ts` (referenced in `bunfig.toml`).
47
+
48
+
Shell-integration tests use [bats-core](https://github.com/bats-core/bats-core) (`brew install bats-core` or install via your package manager). They cover `install_completions()` from `install.sh` and are located in `install.test.bats`.
46
49
47
50
## Linting & formatting
48
51
@@ -58,7 +61,7 @@ Always run `bun run lint` and `bun run format:check` before considering a change
58
61
## Project layout
59
62
60
63
```
61
-
github-code-search.ts # CLI entry point — Commander subcommands: query, upgrade
- Only pure functions need tests; `tui.ts` and `api.ts` are not unit-tested.
109
115
`api-utils.ts` is the exception: its helpers are unit-tested by mocking `globalThis.fetch`.
110
116
`cache.ts` is also tested: it uses the `GITHUB_CODE_SEARCH_CACHE_DIR` env var override to redirect to a temp directory, so tests have no filesystem side effects on the real cache dir.
117
+
`completions.ts` is fully unit-tested (`completions.test.ts`). Tests that exercise `getCompletionFilePath()` must unset `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, and `ZDOTDIR` in `beforeEach` (and restore them in `afterEach`) to avoid contamination from the CI runner environment.
111
118
- When adding a function to an existing module, add the corresponding test case in the existing `<module>.test.ts`.
112
119
- When creating a new module that contains pure functions, create a companion `<module>.test.ts`.
113
120
- Tests must be self-contained: no network calls, no filesystem side effects.
@@ -229,5 +236,8 @@ For minor/major releases update `docs/blog/index.md` to add a row in the version
229
236
- The `--exclude-repositories` and `--exclude-extracts` options accept both short (`repoName`) and long (`org/repoName`) forms — this normalisation happens in `aggregate.ts`.
230
237
- The `--group-by-team-prefix` option requires a `read:org` GitHub token scope; this is documented in `README.md`.
231
238
- The `upgrade` subcommand replaces the running binary in-place using `src/upgrade.ts`; be careful with filesystem operations there.
239
+
- After a successful upgrade, `refreshCompletions()` (in `src/upgrade.ts`) silently overwrites the existing completion file if one is already present. It never creates a file from scratch — installation is the user's responsibility (via `install.sh` or the `completions` subcommand).
240
+
- The `completions` subcommand (in `github-code-search.ts`) prints the completion script for the detected (or specified) shell to stdout. It is a thin wrapper around `generateCompletion()` in `src/completions.ts`.
241
+
- Shell-integration tests for `install.sh` live in `install.test.bats` and require `bats-core`. Run them with `bun run test:bats`. The CI runs them in a dedicated `test-bats` job using `bats-core/bats-action`.
232
242
-`picocolors` is the only styling dependency; do not add `chalk` or similar.
233
243
- Keep `knip` clean: every exported symbol must be used; every import must resolve.
install.test.bats # Shell-integration tests for install.sh (bats-core)
50
54
```
51
55
52
56
## Running tests
53
57
54
58
```bash
55
-
bun test
59
+
bun test# TypeScript unit tests (co-located *.test.ts files)
60
+
bun run test:bats # Shell-integration tests for install.sh (requires bats-core)
56
61
```
57
62
58
-
Tests are co-located with their source files and cover the pure functions in `aggregate.ts`, `output.ts`, `render.ts`, `render/highlight.ts`, and `upgrade.ts`.
63
+
TypeScript tests are co-located with their source files and cover the pure functions in `aggregate.ts`, `completions.ts`, `output.ts`, `render.ts`, `render/highlight.ts`, and `upgrade.ts`.
64
+
65
+
Shell-integration tests use [bats-core](https://github.com/bats-core/bats-core). Install it once with:
0 commit comments