Files
abcmidi/tests/golden/midi2abc_coleraine.txt
Ronan Keryell 1d766a85d2 Implement basic testing infrastructure (#19)
* Add configuration for CMake build system alongside autoconf

- Add a modern CMake build system (`CMakeLists.txt`, `CMakePresets.json`) that coexists with the legacy
autoconf/Makefile build
- Shared source files (`midifile.c`, `parseabc.c`, `music_utils.c`, `parser2.c`) are compiled once via OBJECT
libraries and linked into the 8 binaries
- Three presets: `default` (Release), `debug`, `sanitize` (ASan + UBSan)
- Generates `compile_commands.json` for clangd/LSP editor support
- Install rules match the legacy Makefile (binaries, doc files, man pages)
- Pinned to `-std=gnu89` because the codebase mixes K&R `()` and ANSI typed prototypes — in C23/gnu23 (GCC 15+
default), `()` means `(void)`, making these a hard error. Note: **the existing autoconf build is also broken with
GCC 15** for the same reason

```sh
cmake --preset debug
cmake --build --preset debug
cmake --install build/debug --prefix /usr/local

Documentation

- README.md: added Building section with both autoconf and CMake instructions
- doc/readme.txt: added build instructions in the existing preamble
- doc/CHANGES: added changelog entry

Test plan

- All 3 presets configure and build with GCC 15
- Smoke test: abc2midi samples/coleraine.abc produces valid MIDI through mftext
- Sanitizer build (--preset sanitize) runs clean on sample files
- Install layout verified: 8 binaries, 10 doc files, 8 man pages in correct paths
- Build on macOS (untested, should work with AppleClang)

* Implement basic testing infrastructure

The CMake build includes a test suite covering all 8 programs:

- **Smoke tests** verify each binary runs cleanly with `-ver`.
- **Golden-file tests** run each program on a sample input and compare the
  (normalized) output to a checked-in reference. Binary MIDI outputs are
  piped through `mftext` to produce diffable text. Volatile lines (version
  banners, dates, temporary paths) are stripped before comparison.

```sh
ctest --preset debug

ctest --preset debug -L golden
ctest --preset debug -L smoke
```

To regenerate the golden files after an intentional behavioural change,
review the diff, then commit:

```sh
cmake --build build/debug --target update-golden
git diff tests/golden/
```

* Factorize more the test CMake code
2026-04-22 07:42:29 -04:00

149 lines
3.0 KiB
Plaintext

calling midi2abc
X: 1
T: from midi2abc_coleraine.mid
M: 6/8
L: 1/8
Q:1/4=142
K:C % 0 sharps
V:1
%%MIDI program 26
%%MIDI program 72
EE>A AAB| \
cB>e ee2| \
dc>A AAB| \
cB^G EE2|
EE>A AAB| \
cB>e ee2| \
dc>B AB^G| \
EA4-A|
EE>A AAB| \
cB>e ee2| \
dc>A AAB| \
cB^G EE2|
EE>A AAB| \
cB>e ee2| \
dc>B AB^G| \
EA4-A|
Bc2 ccd| \
cBd gg2| \
^ga>e dcB| \
A^GB GE^F|
^GAG ABA| \
Bcd efe| \
dc>B AB^G| \
EA4-A|
Bc2 ccd| \
cBd gg2| \
^ga>e dcB| \
A^GB GE^F|
^GAG ABA| \
Bcd efe| \
dc>B AB^G| \
EA4-A|
V:2
%%MIDI program 3
%%MIDI program 3
E,,A,,z [ECA,]A,,z| \
[ECA,]E,,z [DB,^G,E,]E,,z| \
[DB,^G,E,]A,,z [ECA,]A,,z| \
[ECA,]E,,z [DB,^G,E,]E,,z|
[DB,^G,E,]A,,z [ECA,]A,,z| \
[ECA,]E,,z [DB,^G,E,]E,,z| \
[DB,^G,E,]A,,z [ECA,]E,,z| \
[DB,^G,E,]A,,z [ECA,]A,,z|
[DB,^G,E,]A,,z [ECA,]A,,z| \
[ECA,]E,,z [DB,^G,E,]E,,z| \
[DB,^G,E,]A,,z [ECA,]A,,z| \
[ECA,]E,,z [DB,^G,E,]E,,z|
[DB,^G,E,]A,,z [ECA,]A,,z| \
[ECA,]E,,z [DB,^G,E,]E,,z| \
[DB,^G,E,]A,,z [ECA,]E,,z| \
[DB,^G,E,]A,,z [ECA,]A,,z|
[FDB,G,]C,,z [G,E,C,]C,,z| \
[G,E,C,]G,,z [DB,G,]E,,z| \
[B,^G,E,]A,,z [ECA,]A,,z| \
[ECA,]E,,z [DB,^G,E,]E,,z|
[DB,^G,E,]A,,z [ECA,]E,,z| \
[DB,^G,E,]A,,z [ECA,]D,,z| \
[A,F,D,]A,,z [ECA,]E,,z| \
[DB,^G,E,]A,,z [ECA,]A,,z|
[FDB,G,]C,,z [G,E,C,]C,,z|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