Skip to content

Commit e9b6701

Browse files
committed
run tests only during the build
1 parent dcd34df commit e9b6701

File tree

4 files changed

+6
-76
lines changed

4 files changed

+6
-76
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,16 @@ on:
99
jobs:
1010
build-and-test:
1111
runs-on: ubuntu-latest
12-
12+
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
16-
16+
1717
- name: Install Nix
1818
uses: cachix/install-nix-action@v27
1919
with:
2020
extra_nix_config: |
2121
experimental-features = nix-command flakes
22-
23-
- name: Build with Nix
22+
23+
- name: Build and test
2424
run: nix build
25-
26-
- name: Run core tests
27-
run: |
28-
export LGX_BINARY="$(pwd)/result/bin/lgx"
29-
./result/bin/lgx_tests
30-
31-
- name: Run library tests
32-
run: ./result/bin/lgx_lib_tests

README.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,7 @@ The C API header will be at `./result/include/lgx.h`.
133133

134134
#### Running Tests with Nix
135135

136-
After building with `nix build '.'` or `nix build '.#all'`, run the tests:
137-
138-
```bash
139-
# Run core tests (including CLI integration tests)
140-
export LGX_BINARY="$(pwd)/result/bin/lgx"
141-
./result/bin/lgx_tests
142-
143-
# Run library API tests
144-
./result/bin/lgx_lib_tests
145-
```
146-
147-
**Note:** The `LGX_BINARY` environment variable tells the CLI tests where to find the `lgx` binary. Without it, the CLI integration tests will be skipped (though all other tests will still run).
136+
Tests run automatically during `nix build`. The build will fail if any tests do not pass.
148137

149138
**Note:** If you haven't enabled flakes, you'll need to add the experimental features flag:
150139

@@ -212,13 +201,6 @@ This will create:
212201
```bash
213202
mkdir build
214203
cd build
215-
cmake .. -DLGX_BUILD_TESTS=ON
216-
make -j$(nproc)
217-
```
218-
219-
To also test the library:
220-
221-
```bash
222204
cmake .. -DLGX_BUILD_TESTS=ON -DLGX_BUILD_SHARED=ON
223205
make -j$(nproc)
224206
```
@@ -229,9 +211,3 @@ make -j$(nproc)
229211
cd build
230212
ctest --output-on-failure
231213
```
232-
233-
Or run the test executable directly:
234-
235-
```bash
236-
./build/lgx_tests
237-
```

docs/project.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -596,37 +596,13 @@ This builds:
596596

597597
**Running Tests with CMake:**
598598

599-
Tests are built using Google Test and can be run via CMake's CTest or directly:
599+
Tests are built using Google Test and can be run via CMake's CTest:
600600

601601
```bash
602602
cd build
603603
ctest --output-on-failure
604604
```
605605

606-
Or run test executables directly:
607-
608-
```bash
609-
# Core tests (including CLI integration tests)
610-
./build/tests/lgx_tests
611-
612-
# Library API tests (requires shared library build)
613-
./build/tests/lgx_lib_tests
614-
```
615-
616-
**CLI Integration Tests:**
617-
618-
The CLI tests (`test_cli.cpp`) require the `lgx` binary to be available. They will:
619-
1. Check for `LGX_BINARY` environment variable first
620-
2. Search common locations (build directory, parent directories)
621-
3. Skip if binary is not found
622-
623-
To run CLI tests explicitly:
624-
625-
```bash
626-
export LGX_BINARY="$(pwd)/build/lgx"
627-
./build/tests/lgx_tests
628-
```
629-
630606
**Installation:**
631607

632608
To install the built binaries and libraries system-wide:

nix/all.nix

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,6 @@ pkgs.stdenv.mkDerivation {
5252
mkdir -p $out/include
5353
cp ${src}/src/lgx.h $out/include/
5454
55-
# Install test executables
56-
mkdir -p $out/bin
57-
cp build/tests/lgx_tests $out/bin/
58-
cp build/tests/lgx_lib_tests $out/bin/
59-
60-
# Fix rpath for lgx_lib_tests to find the shared library
61-
if [ -f $out/bin/lgx_lib_tests ]; then
62-
if [[ "$OSTYPE" == "darwin"* ]]; then
63-
install_name_tool -add_rpath $out/lib $out/bin/lgx_lib_tests
64-
else
65-
patchelf --set-rpath $out/lib:$(patchelf --print-rpath $out/bin/lgx_lib_tests) $out/bin/lgx_lib_tests
66-
fi
67-
fi
68-
6955
runHook postInstall
7056
'';
7157

0 commit comments

Comments
 (0)