Skip to content

Commit 88e2275

Browse files
committed
Added support for mutation testing using Mull.
1 parent ccda265 commit 88e2275

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

.github/workflows/mutation.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
concurrency:
6+
group: environment-${{github.ref}}
7+
cancel-in-progress: true
8+
9+
env:
10+
DISPLAY: ":99" # Display number to use for the X server
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
build:
18+
name: ${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }}
19+
runs-on: ${{ matrix.platform.os }}
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
platform:
25+
- { name: Linux Clang, os: ubuntu-24.04, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -GNinja }
26+
config:
27+
- { name: Static, flags: -DBUILD_SHARED_LIBS=OFF }
28+
type:
29+
- { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=ON }
30+
31+
steps:
32+
- name: Checkout Code
33+
uses: actions/checkout@v4
34+
35+
- name: Get CMake and Ninja
36+
uses: lukka/get-cmake@latest
37+
with:
38+
cmakeVersion: '3.22'
39+
ninjaVersion: latest
40+
41+
- name: Install Linux Dependencies and Tools
42+
if: runner.os == 'Linux'
43+
run: |
44+
curl -1sLf 'https://dl.cloudsmith.io/public/mull-project/mull-stable/setup.deb.sh' | sudo -E bash
45+
CLANG_VERSION=$(clang++ --version | sed -n 's/.*version \([0-9]\+\)\..*/\1/p')
46+
echo "CLANG_VERSION=$CLANG_VERSION" >> $GITHUB_ENV
47+
sudo apt-get update && sudo apt-get install xorg-dev libxrandr-dev libxcursor-dev libxi-dev libudev-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev x11-utils xvfb fluxbox eterm daemonize lib32stdc++6 llvm-$CLANG_VERSION mull-$CLANG_VERSION
48+
mull-runner-$CLANG_VERSION --version
49+
50+
- name: Remove ALSA Library
51+
if: runner.os == 'Linux'
52+
run: sudo apt-get remove -y libasound2
53+
54+
- name: Configure CMake
55+
run: cmake --preset dev -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.type.flags}} -DCMAKE_CXX_FLAGS="-stdlib=libc++ -O0 -fpass-plugin=/usr/lib/mull-ir-frontend-$CLANG_VERSION -g -grecord-command-line -fprofile-instr-generate -fcoverage-mapping"
56+
57+
- name: Build
58+
run: cmake --build build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
59+
60+
- name: Prepare Test
61+
run: |
62+
set -e
63+
set -o pipefail
64+
# Start up Xvfb and fluxbox to host display tests
65+
daemonize /usr/bin/Xvfb $DISPLAY -screen 0 1920x1080x24 -ac +extension GLX +extension DPMS +render -noreset -s 1440 +bs -maxclients 256 +xinerama
66+
sleep 5
67+
daemonize /usr/bin/fluxbox
68+
sleep 5
69+
# Test if the X server is working properly by outputting display information
70+
xdpyinfo -queryExtensions | awk "/^name of display/,/^ significant bits in color specification/"
71+
# Make sure the build/bin directory exists so that the find command does not fail if no executables are built
72+
mkdir -p build/bin
73+
# Make use of a test to print OpenGL vendor/renderer/version info to the console
74+
find build/bin -name test-sfml-window -or -name test-sfml-window.exe -exec sh -c "{} *sf::Context* --section=\"Version String\" --success | grep OpenGL" \;
75+
76+
- name: Test
77+
run: |
78+
cd test
79+
mull-runner-$CLANG_VERSION --allow-surviving --reporters SQLite --report-name SFML ../build/bin/test-sfml-system
80+
mull-runner-$CLANG_VERSION --allow-surviving --reporters SQLite --report-name SFML ../build/bin/test-sfml-network
81+
mull-runner-$CLANG_VERSION --allow-surviving --reporters SQLite --report-name SFML ../build/bin/test-sfml-audio
82+
mull-runner-$CLANG_VERSION --allow-surviving --reporters SQLite --report-name SFML ../build/bin/test-sfml-window
83+
mull-runner-$CLANG_VERSION --allow-surviving --reporters SQLite --report-name SFML ../build/bin/test-sfml-graphics
84+
85+
- name: Report (IDE)
86+
run: mull-reporter-$CLANG_VERSION --reporters IDE test/SFML.sqlite
87+
88+
- name: Report (Github Annotations)
89+
run: mull-reporter-$CLANG_VERSION --reporters GithubAnnotations test/SFML.sqlite

mull.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
mutators:
2+
- cxx_add_assign_to_sub_assign # Replaces += with -=
3+
- cxx_add_to_sub # Replaces + with -
4+
- cxx_and_assign_to_or_assign # Replaces &= with |=
5+
- cxx_and_to_or # Replaces & with |
6+
- cxx_assign_const # Replaces 'a = b' with 'a = 42'
7+
- cxx_bitwise_not_to_noop # Replaces ~x with x
8+
- cxx_div_assign_to_mul_assign # Replaces /= with *=
9+
- cxx_div_to_mul # Replaces / with *
10+
- cxx_eq_to_ne # Replaces == with !=
11+
- cxx_ge_to_gt # Replaces >= with >
12+
- cxx_ge_to_lt # Replaces >= with <
13+
- cxx_gt_to_ge # Replaces > with >=
14+
- cxx_gt_to_le # Replaces > with <=
15+
- cxx_init_const # Replaces 'T a = b' with 'T a = 42'
16+
- cxx_le_to_gt # Replaces <= with >
17+
- cxx_le_to_lt # Replaces <= with <
18+
- cxx_logical_and_to_or # Replaces && with ||
19+
- cxx_logical_or_to_and # Replaces || with &&
20+
- cxx_lshift_assign_to_rshift_assign # Replaces <<= with >>=
21+
- cxx_lshift_to_rshift # Replaces << with >>
22+
- cxx_lt_to_ge # Replaces < with >=
23+
- cxx_lt_to_le # Replaces < with <=
24+
- cxx_minus_to_noop # Replaces -x with x
25+
- cxx_mul_assign_to_div_assign # Replaces *= with /=
26+
- cxx_mul_to_div # Replaces * with /
27+
- cxx_ne_to_eq # Replaces != with ==
28+
- cxx_or_assign_to_and_assign # Replaces |= with &=
29+
- cxx_or_to_and # Replaces | with &
30+
- cxx_post_dec_to_post_inc # Replaces x-- with x++
31+
- cxx_post_inc_to_post_dec # Replaces x++ with x--
32+
- cxx_pre_dec_to_pre_inc # Replaces --x with ++x
33+
- cxx_pre_inc_to_pre_dec # Replaces ++x with --x
34+
- cxx_rem_assign_to_div_assign # Replaces %= with /=
35+
- cxx_rem_to_div # Replaces % with /
36+
- cxx_remove_negation # Replaces !a with a
37+
- cxx_remove_void_call # Removes calls to a function returning void
38+
- cxx_replace_scalar_call # Replaces call to a function with 42
39+
- cxx_rshift_assign_to_lshift_assign # Replaces >>= with <<=
40+
- cxx_rshift_to_lshift # Replaces << with >>
41+
- cxx_sub_assign_to_add_assign # Replaces -= with +=
42+
- cxx_sub_to_add # Replaces - with +
43+
- cxx_xor_assign_to_or_assign # Replaces ^= with |=
44+
- cxx_xor_to_or # Replaces ^ with |
45+
- negate_mutator # Negates conditionals !x to x and x to !x
46+
- scalar_value_mutator # Replaces zeros with 42, and non-zeros with 0
47+
excludePaths:
48+
- .*/catch2/.*
49+
- .*/test/.*

0 commit comments

Comments
 (0)