Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Dec 3, 2020
1 parent 499595a commit 2a1df75
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.build_version }}
name: Julia ${{ matrix.version }} - ${{ matrix.build_spec }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -19,14 +19,14 @@ jobs:
- ubuntu-latest
arch:
- x64
build_version:
build_spec:
- v1.5.0 # entry straight in Versions.toml
- nightly # entry from Builds.toml
- 8cb458c6dcd8e067a3bd430b006efb0dfde56cf9 # directly from Git, never built
- master # directly from Git, likely built
env:
JULIA_DEBUG: NewPkgEval
JULIA_VERSION: ${{ matrix.build_version }}
JULIA_SPEC: ${{ matrix.build_spec }}
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand Down
34 changes: 22 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
using PkgEval
using Test

# determine the version to use
const version = get(ENV, "JULIA_VERSION", string(VERSION))
@info "Testing with Julia $version"
const julia = PkgEval.obtain_julia(version)::VersionNumber
@info "Resolved to Julia v$julia"
const install = PkgEval.prepare_julia(julia)
# determine which Julia to use
const julia_spec = get(ENV, "JULIA_SPEC", string(VERSION))
@info "Testing with Julia $julia_spec"
const julia_version = PkgEval.obtain_julia(julia_spec)::VersionNumber
@info "Resolved to Julia v$julia_version"
const julia_install = PkgEval.prepare_julia(julia_version)

@testset "sandbox" begin
PkgEval.prepare_runner()
mktemp() do path, io
PkgEval.run_sandboxed_julia(install, `-e 'print(1337)'`; stdout=io,
PkgEval.run_sandboxed_julia(julia_install, `-e 'print(1337)'`; stdout=io,
tty=false, interactive=false)
close(io)
@test read(path, String) == "1337"
end

# print versioninfo so we can verify in CI logs that the correct version is used
PkgEval.run_sandboxed_julia(install, `-e 'using InteractiveUtils; versioninfo()'`;
PkgEval.run_sandboxed_julia(julia_install, `-e 'using InteractiveUtils; versioninfo()'`;
tty=false, interactive=false)
end

Expand All @@ -30,13 +30,23 @@ const pkgnames = ["TimerOutputs", "Crayons", "Example", "Gtk"]
pkgs = PkgEval.read_pkgs(pkgnames)

# timeouts
results = PkgEval.run([julia], pkgs; time_limit = 0.1)
results = PkgEval.run([Configuration(julia=julia_version)], pkgs; time_limit = 0.1)
@test all(results.status .== :kill)
end

@testset "main entrypoint" begin
results = PkgEval.run([julia], pkgnames)
if !(version == "master" || version == "nightly")
results = PkgEval.run([Configuration(julia=julia_version)], pkgnames)
if !(julia_version == "master" || julia_version == "nightly")
@test all(results.status .== :ok)
for result in eachrow(results)
@test occursin("Testing $(result.name) tests passed", result.log)
end
end
end

@testset "PackageCompiler" begin
results = PkgEval.run([Configuration(julia=julia_version, compiled=true)], ["Example"])
if !(julia_version == "master" || julia_version == "nightly")
@test all(results.status .== :ok)
for result in eachrow(results)
@test occursin("Testing $(result.name) tests passed", result.log)
Expand All @@ -52,4 +62,4 @@ end
end

PkgEval.purge()
rm(install; recursive=true)
rm(julia_install; recursive=true)

0 comments on commit 2a1df75

Please sign in to comment.