A modular CLI tester for the 42 push_swap project.
It validates:
- parser/error behavior (
EXPECT_ERRORcases) - sorting correctness with
checker - move-based scoring (
100 < 700,500 < 5500) - memory leaks with
valgrind
It also provides:
- ASCII table output
- Unicode status symbols (
✔,✘) - live progress bar with
PASS/FAILcounters - final success/fail summary
push_swap_tester/
├── Makefile
├── includes/
│ ├── tester.h
│ ├── colors.h
│ └── config.h
├── src/
│ ├── engine/
│ │ ├── executor.c
│ │ ├── judge.c
│ │ └── ui.c
│ ├── utils/
│ │ ├── generator.c
│ │ └── str_utils.c
│ └── main.c
└── tests/
└── cases.c
- Linux/macOS
- C compiler (
cc) makevalgrind- your compiled
push_swapbinary - a checker binary (
checker/checker_linux/checker_Mac)
For the smoothest setup, keep both binaries in your push_swap project root:
push_swapin project rootcheckerin project root
Example:
push_Swap/
├── push_swap
├── checker
└── ...
If binaries are not in root, use environment variables (PUSH_SWAP_BIN,
PUSH_SWAP_CHECKER) as shown below.
makeRebuild from scratch:
make reThe tester auto-detects binaries from common locations:
./push_swap../push_swap/push_swap../push_Swap/push_swap
Checker candidates:
./checker../push_swap/checker../push_Swap/checker./checker_linux./checker_Mac
You can also override paths with environment variables:
PUSH_SWAP_BIN=/absolute/path/to/push_swap \
PUSH_SWAP_CHECKER=/absolute/path/to/checker \
./push_swap_testerDefault:
./push_swap_testerWith mode:
./push_swap_tester --mode simple
./push_swap_tester --mode medium
./push_swap_tester --mode complex
./push_swap_tester --mode adaptivesimple: manual test cases only (tests/cases.c)medium: manual + randomn=100complex: manual + randomn=500adaptive: manual + randomn=100+ randomn=500
RESULT: PASS / FAILSORT: checker status (OK,KO,SKIP)LEAK: valgrind status (CLEAN,LEAK,CRASH,SKIP)CHARS: input character count used for that testSCORE: move score (x/5for valid sorting tests)
- Build your
push_swapproject. - Place tester near your project (or set env path overrides).
- Run:
./push_swap_tester --mode simple- If simple passes, run heavier suites:
./push_swap_tester --mode medium
./push_swap_tester --mode complexSet explicit path:
PUSH_SWAP_BIN=/path/to/push_swap ./push_swap_testerSet explicit checker path:
PUSH_SWAP_CHECKER=/path/to/checker ./push_swap_testerInstall valgrind, then retry.
Replay a failing case directly:
ARG="3 2 1 0 -1"
./push_swap "$ARG" | ./checker "$ARG"If direct run returns OK but tester says KO, verify tester version and rebuild:
make re- Manual cases live in
tests/cases.c. - You can freely add/remove cases there.
- Exit code is non-zero when any test fails.