Skip to content

Commit f5310d5

Browse files
committed
xx-macports: add tests
Signed-off-by: CrazyMax <[email protected]>
1 parent 9df8a41 commit f5310d5

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

docker-bake.hcl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ group "test" {
5858
"test-verify",
5959
"test-clang",
6060
"test-go",
61-
"test-cargo"
61+
"test-cargo",
62+
"test-macports"
6263
]
6364
}
6465

@@ -97,6 +98,11 @@ target "test-cargo" {
9798
target = "test-cargo"
9899
}
99100

101+
target "test-macports" {
102+
inherits = ["test-base"]
103+
target = "test-macports"
104+
}
105+
100106
group "validate" {
101107
targets = ["shfmt-validate", "shellcheck"]
102108
}

src/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ COPY --from=build /out/ /usr/bin/
1818

1919
FROM --platform=$BUILDPLATFORM tonistiigi/bats-assert AS bats-assert
2020

21+
# osxcross for usage with macports: https://github.com/tpoechtrager/osxcross/blob/master/README.MACPORTS.md
22+
FROM --platform=$BUILDPLATFORM crazymax/osxcross:13.1 AS osxcross
23+
2124
FROM ${TEST_BASE_IMAGE} AS test-base-alpine
2225
RUN --mount=type=cache,target=/pkg-cache \
2326
ln -s /pkg-cache /etc/apk/cache && \
@@ -92,6 +95,10 @@ FROM test-base-fixtures AS test-cargo
9295
COPY test-cargo.bats test_helper.bash ./
9396
RUN --mount=type=cache,target=/pkg-cache,sharing=locked ./test-cargo.bats
9497

98+
FROM test-base AS test-macports
99+
COPY test-macports.bats test_helper.bash ./
100+
ENV PATH="/osxcross/bin:$PATH"
101+
RUN --mount=type=cache,target=/pkg-cache,sharing=locked --mount=from=osxcross,source=/osxcross,target=/osxcross ./test-macports.bats
95102

96103
# these targets can be overwritten with build contexts
97104
FROM scratch AS sdk-extras

src/test-macports.bats

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bats
2+
3+
load 'assert'
4+
load 'test_helper'
5+
6+
@test "install" {
7+
add openssl wget
8+
assert_success
9+
10+
export TARGETOS=darwin
11+
export OSXCROSS_TARGET_DIR=/tmp/macports
12+
run xx-macports --static install jq
13+
assert_success
14+
assert_output --partial "installed jq"
15+
run test -e "${OSXCROSS_TARGET_DIR}/macports/pkgs/opt/local/bin/jq"
16+
}

0 commit comments

Comments
 (0)