Skip to content

Commit

Permalink
allow tests on musl platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Dec 26, 2019
1 parent 4d0914f commit e9c66fd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
5 changes: 1 addition & 4 deletions .ci-scripts/test-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/sh

triple="$(cc -dumpmachine)"
libc="${triple##*-}"

rm -rf \
/usr/local/bin/ponyc \
/usr/local/bin/stable \
Expand All @@ -13,7 +10,7 @@ rm -rf \
cat ponyup-init.sh | sh -s -- --prefix=/usr/local

export PATH=$HOME/.local/share/ponyup/bin:$PATH
ponyup update ponyc nightly --libc=${libc}
ponyup update ponyc nightly "--platform=$(cc -dumpmachine)"
ponyup update changelog-tool nightly
ponyup update corral nightly
ponyup update stable nightly
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Test with the most recent ponyc release
run: make test
run: PONYUP_PLATFORM=musl make test
- name: Bootstrap test
run: .ci-scripts/test-bootstrap.sh

Expand Down
3 changes: 2 additions & 1 deletion cmd/packages.pony
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ primitive Packages
else error
end
var libc: Libc =
if name == "ponyc" then Glibc
if (name == "ponyc") and (os is Linux) then Glibc
else None
end
for field in platform.values() do
Expand All @@ -31,6 +31,7 @@ primitive Packages
else error
end
end
if (os is Darwin) then libc = None end
Package._create(name, channel, version, (cpu, os, libc))

fun from_string(str: String): Package ? =>
Expand Down
23 changes: 17 additions & 6 deletions test/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _TestSync is UnitTest
fun apply(h: TestHelper) ? =>
let auth = h.env.root as AmbientAuth
_SyncTester(h, auth, _pkg_name)
h.long_test(20_000_000_000)
h.long_test(30_000_000_000)

class _TestSelect is UnitTest
let _ponyc_versions: Array[String] val =
Expand All @@ -41,9 +41,9 @@ class _TestSelect is UnitTest
"select"

fun apply(h: TestHelper) ? =>
let platform = _TestPonyup.platform(h.env.vars)
let install_args: {(String): Array[String] val} val =
// TODO: libc
{(v) => ["update"; "ponyc"; v; "--platform=" + "gnu"] }
{(v) => ["update"; "ponyc"; v; "--platform=" + platform] }

let link =
FilePath(
Expand Down Expand Up @@ -74,7 +74,7 @@ class _TestSelect is UnitTest
end
} val)?

h.long_test(20_000_000_000)
h.long_test(30_000_000_000)

actor _SyncTester is PonyupNotify
let _h: TestHelper
Expand All @@ -87,11 +87,12 @@ actor _SyncTester is PonyupNotify
_auth = auth
_pkg_name = pkg_name

let platform = _TestPonyup.platform(h.env.vars)
let http_get = HTTPGet(NetAuth(_auth), this)
for channel in ["nightly"; "release"].values() do
try
// TODO: specify libc
let pkg = Packages.from_fragments(_pkg_name, channel, "latest", [])?
let pkg = Packages.from_fragments(
_pkg_name, channel, "latest", platform.split("-"))?
let query_string: String =
Cloudsmith.repo_url(channel).clone()
.> append(Cloudsmith.query(pkg))
Expand Down Expand Up @@ -144,6 +145,16 @@ actor _SyncTester is PonyupNotify
_h.env.out.write(str)

primitive _TestPonyup
fun platform(vars: Array[String] box): String =>
let key = "PONYUP_PLATFORM"
var platform' = ""
for v in vars.values() do
if not v.contains(key) then continue end
platform' = v.substring(key.size().isize() + 1)
break
end
platform'

fun ponyup_bin(auth: AmbientAuth): FilePath? =>
FilePath(auth, "./build")?
.join(if Platform.debug() then "debug" else "release" end)?
Expand Down

0 comments on commit e9c66fd

Please sign in to comment.