Skip to content

Commit

Permalink
CI: add basic Meson testing
Browse files Browse the repository at this point in the history
I've tried to be a bit more minimal here than the CMake tests are, since
there's already a good cross section of testing there. For Meson, I just
want to touch test each of the major platforms to ensure that it works
  • Loading branch information
dcbaker committed Mar 18, 2024
1 parent fda84fb commit 8dd0b2e
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 14 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Meson

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch:

jobs:
build-ubuntu:
name: Build and Test on Ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
- uses: BSFishy/[email protected]
with:
action: test
meson-version: 0.64.1

build-macos:
name: Build and Test on MacOS
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
- uses: BSFishy/[email protected]
with:
action: test
meson-version: 0.64.1

build-windows:
name: Build and Test on Windows
runs-on: windows-latest
env:
CXX: clang-cl
steps:
- uses: ilammy/msvc-dev-cmd@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
- uses: BSFishy/[email protected]
with:
action: test
setup-options: -Dcpp_std=c++14 # Clang-CL doesn't actually support C++11, hide the warning
meson-version: 0.64.1
15 changes: 1 addition & 14 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,7 @@ endif

with_tests = get_option('tests').disable_auto_if(meson.is_subproject()).allowed()
if with_tests
test(
'link',
executable(
'link_test',
'test/link_a.cpp', 'test/link_b.cpp',
dependencies : dep_icu,
include_directories : 'include',
)
)

# Fuzzer test is not as trivial as it should be

# Meson can generate basic cmake-configs files, but not when targets are used,
# so these tests don't make sense
subdir('test')
endif

extra_cflags = []
Expand Down
55 changes: 55 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright © 2024 Dylan Baker
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

inc = include_directories('../include')

test(
'link',
executable(
'link_test',
'link_a.cpp', 'link_b.cpp',
dependencies : dep_icu,
include_directories : inc,
)
)

test(
'options',
executable(
'options_test',
'main.cpp', 'options.cpp',
dependencies : dep_icu,
include_directories : inc,
)
)

if cpp.get_id() == 'clang' and host_machine.system() == 'linux'
executable(
'fuzzer',
'fuzz.cpp',
cpp_args : ['-fsanitize=fuzzer'],
link_args : ['-fsanitize=fuzzer'],
dependencies : dep_icu,
include_directories : inc,
)
endif

# Meson can generate basic cmake-configs files, but not when targets are used,
# so these tests don't make sense

0 comments on commit 8dd0b2e

Please sign in to comment.