Skip to content

Commit f600dcb

Browse files
committed
Build and test the bindgen docker image
1 parent 9b643c9 commit f600dcb

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ script:
99
docker-compose run --rm $TEST_ENV scripts/scalafmt --test;
1010
docker-compose run --rm $TEST_ENV scripts/clangfmt --test;
1111
fi
12+
- if [[ "$TEST_ENV" = *llvm-6.0 ]]; then
13+
docker-compose build bindgen;
14+
scripts/docker-test.sh;
15+
fi
1216

1317
matrix:
1418
include:

scripts/docker-bindgen.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#
3+
# Wrapper script for running the dockerized scala-native-bindgen binary.
4+
5+
set -euo pipefail
6+
IFS=$'\n\t'
7+
8+
volumes=(
9+
"--volume=$(pwd):/src"
10+
"--volume=/usr/include:/usr/include"
11+
)
12+
13+
if [[ "$#" -gt 1 ]] && [[ "$1" == /* ]]; then
14+
volumes+="--volume=$1:$1"
15+
fi
16+
17+
exec docker run --rm "${volumes[@]}" scalabindgen/scala-native-bindgen "$@"

scripts/docker-test.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
#
3+
# Run tests similar to the BindgenSpec using the dockerized bindgen
4+
# program.
5+
#
6+
# Assumes you have built the bindgen docker image by running:
7+
#
8+
# docker-compose build bindgen
9+
10+
set -euo pipefail
11+
IFS=$'\n\t'
12+
13+
outdir="tests/target/docker-samples"
14+
rm -rf "$outdir"
15+
mkdir "$outdir"
16+
17+
for input in tests/samples/*.h; do
18+
name="$(basename "$input" .h)"
19+
output="$outdir/$name.scala"
20+
expected="tests/samples/$name.scala"
21+
22+
echo "Testing $name"
23+
scripts/docker-bindgen.sh "$input" \
24+
--name="$name" \
25+
--link=bindgentests \
26+
--package=org.scalanative.bindgen.samples \
27+
--exclude-prefix=__ \
28+
-- > "$output"
29+
git diff --exit-code "$expected" "$output"
30+
done

0 commit comments

Comments
 (0)