Skip to content

Commit

Permalink
Improving detection of garbage collection bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielsferre committed Jul 24, 2024
1 parent a3fbfdd commit e1082c7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ Flag | Effect
./run-tests -k | Run all tests even if some tests are failing
./run-tests -o gtest | The gtest output format might be easier to read if you are using print statements for debugging.

For convenience, when the test script is run without any parameters, it also runs the linter at the end.
For convenience, when the test script is run without any busted parameters, it also runs the linter at the end.

#### Testing garbage collection

Doing proper GC testing takes longer, so we have a special mode for doing that.
For testing garbage collection more carefully, pass "gc" as the first parameter
of the script. The rest of the parameters will do the same as before:

```sh
$ ./run-tests gc # Run all tests but with proper GC testing
$ ./run-tests gc spec/parser_spec.lua # Run just one of the test suite files
# but with proper GC testing
```

### Running the benchmarks suite

Expand Down
13 changes: 12 additions & 1 deletion run-tests
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/bin/bash

# HOW TO USE: This is a wrapper around busted. The command-line arguments are the same.
# HOW TO USE: This is a wrapper around busted. Pass "gc" as the first argument for testing the
# garbage collector. Except for "gc", the command-line arguments are the same of busted
#
# EXAMPLES:
# ./run-tests
# ./run-tests -k
# ./run-tests spec/coder_spec.lua
# ./run-tests gc
# ./run-tests gc -k

test_gc=""
[ "$1" = "gc" ] && test_gc="y" && shift

echo "--- Test Suite ---"

Expand All @@ -21,6 +27,11 @@ FLAGS=(--verbose --no-keep-going)
# Also, add some compiler flags to verify standard compliance.
export CFLAGS='-O0 -std=c99 -Wall -Werror -Wundef -Wpedantic -Wno-unused'

# When testing the garbage collector, we use -O2 for a greater chance of finding bugs.
# The HARDMEMTESTS macro makes lualib do garbage collection whenever it can.
[ -n "$test_gc" ] &&
CFLAGS='-DHARDMEMTESTS -O2 -std=c99 -Wall -Werror -Wundef -Wpedantic -Wno-unused'

if [ "$#" -eq 0 ]; then
if command -v parallel >/dev/null; then
parallel busted -o utfTerminal "${FLAGS[@]}" ::: spec/*_spec.lua
Expand Down

0 comments on commit e1082c7

Please sign in to comment.