summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-12 20:39:36 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-12 20:39:36 +0300
commit71f0b19476adb170c24d6a8de4ab3133701b1aeb (patch)
tree4035f3fe33b38782b96cfdde087dd566256eda92 /tests
parentd505017cec86c000f891b003f5ca3481f5ffae61 (diff)
Fix macOS builds on Apple Silicon and Intel
Diffstat (limited to 'tests')
-rw-r--r--tests/header_test.sh9
-rw-r--r--tests/meson.build2
-rw-r--r--tests/symbols_test.sh11
3 files changed, 20 insertions, 2 deletions
diff --git a/tests/header_test.sh b/tests/header_test.sh
index 6636418..4ba091b 100644
--- a/tests/header_test.sh
+++ b/tests/header_test.sh
@@ -13,4 +13,13 @@ if command -v "$cxx" >/dev/null; then
echo '#include "term.h"' | "$cxx" -std=c++17 -Wall -Wextra -Wpedantic -Werror \
-Iinclude/term -x c++ -fsyntax-only - || { echo "term.h: not valid C++" >&2; status=1; }
fi
+
+# Apple headers define wide before a host includes the Unicode API.
+unicode_header=$'typedef struct wide { int value; } wide;\n#include "unicode/width.h"'
+echo "$unicode_header" | "$cc" -std=c11 -Wall -Wextra -Wpedantic -Werror \
+ -Iinclude/term -x c -fsyntax-only - || { echo "unicode/width.h: conflicts with host types" >&2; status=1; }
+if command -v "$cxx" >/dev/null; then
+ echo "$unicode_header" | "$cxx" -std=c++17 -Wall -Wextra -Wpedantic -Werror \
+ -Iinclude/term -x c++ -fsyntax-only - || { echo "unicode/width.h: conflicts with C++ host types" >&2; status=1; }
+fi
exit $status
diff --git a/tests/meson.build b/tests/meson.build
index 8372574..0aa78e8 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -10,6 +10,7 @@ test_c_args = ['-UNDEBUG']
test_env = environment()
test_env.set('LD_PRELOAD', '')
test_env.set('DYLD_INSERT_LIBRARIES', '')
+test_env.set('NM', find_program('nm', native: true).full_path())
# [name, sources, dependencies, suites]
term_tests = [
@@ -97,6 +98,7 @@ test('term-symbols-test', bash,
args: [files('symbols_test.sh'), term_headless_lib.get_static_lib(),
meson.project_source_root() / 'include' / 'term',
term_headless_lib.get_shared_lib()],
+ env: test_env,
suite: 'unit',
)
test('term-header-test', bash,
diff --git a/tests/symbols_test.sh b/tests/symbols_test.sh
index 4c7aee1..0343eb0 100644
--- a/tests/symbols_test.sh
+++ b/tests/symbols_test.sh
@@ -7,8 +7,15 @@
set -euo pipefail
lib=$1
src=${2:-$(dirname "$0")/../include/term}
+nm=${NM:-nm}
-syms=$(nm -g --defined-only -P "$lib")
+defined_args=(-g --defined-only -P)
+exported_args=(-D --defined-only -P)
+if [[ $(uname -s) == Darwin ]]; then
+ defined_args=(-g -U -P)
+ exported_args=(-g -U -P)
+fi
+syms=$("$nm" "${defined_args[@]}" "$lib")
# ASan adds an __odr_asan.<name> symbol for each global variable.
defined=$(awk 'NF >= 2 && $2 ~ /^[A-Z]$/ && $2 != "U" { print $1 }' <<<"$syms" |
grep -v '^_*odr_asan\.' | sed 's/^_//' | sort -u)
@@ -49,7 +56,7 @@ fi
# The shared library exports term.h and nothing else.
shared=${3:-}
if [[ -n $shared ]]; then
- exported=$(nm -D --defined-only -P "$shared" | awk '$2 ~ /^[TDBRVW]$/ { print $1 }' |
+ exported=$("$nm" "${exported_args[@]}" "$shared" | awk '$2 ~ /^[TDBRVW]$/ { print $1 }' |
sed 's/^_//' | sort -u)
extra=$(comm -13 <(echo "$declared") <(echo "$exported"))
absent=$(comm -23 <(echo "$declared") <(echo "$exported"))