Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests! Green Travis build!! :D #8

Merged
merged 2 commits into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ git:
# packages:
# - gfortran
before_script: # homebrew for mac
- julia -e 'Pkg.add("Blink")'
- julia -e 'Pkg.add("Blink"); Pkg.build("Blink"); using Blink; Blink.AtomShell.install();'

## uncomment the following lines to override the default test script
#script:
Expand Down
43 changes: 32 additions & 11 deletions test/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,45 @@ build_app_jl = joinpath(@__DIR__, "..", "build_app.jl")
examples_blink = joinpath(@__DIR__, "..", "examples", "blink.jl")
examples_hello = joinpath(@__DIR__, "..", "examples", "hello.jl")

builddir = mktempdir()
@assert isdir(builddir)

@testset "HelloWorld.app" begin
@test success(`$julia $build_app_jl $examples_hello "HelloWorld"`)
@test success(`./builddir/HelloWorld.app/Contents/MacOS/hello`)
# Test the build_app.jl script.
# `@test contains(readstring(cmd), "Done building")` tests that the command
# runs, and that gets all the way to the end. This is prefereable to
# `@test success(cmd)`, because `success` suppresses the cmd's output, so we
# can't see where the test is failing.
@test contains(readstring(`$julia $build_app_jl --verbose $examples_hello "HelloWorld" $builddir`),
"Done building")
@test isdir("$builddir/HelloWorld.app")
@test success(`$builddir/HelloWorld.app/Contents/MacOS/hello`)
end

@testset "HelloBlink.app" begin
blinkPkg = Pkg.dir("Blink")
httpParserPkg = Pkg.dir("HttpParser")
mbedTLSPkg = Pkg.dir("MbedTLS")

@test success(`$julia $build_app_jl
-R $(joinpath(blinkPkg, "deps/Julia.app"))
-R $(joinpath(blinkPkg, "src/AtomShell/main.js"))
-R $(joinpath(blinkPkg, "src/content/main.html"))
-R $(joinpath(blinkPkg, "res"))
-L $(joinpath(httpParserPkg, "deps/usr/lib/libhttp_parser.dylib"))
-L $(joinpath(mbedTLSPkg, "deps/usr/lib/libmbedcrypto.2.7.1.dylib"))
$examples_blink "HelloBlink"`)
@test contains(readstring(`$julia $build_app_jl --verbose
-R $(joinpath(blinkPkg, "deps/Julia.app"))
-R $(joinpath(blinkPkg, "src/AtomShell/main.js"))
-R $(joinpath(blinkPkg, "src/content/main.html"))
-R $(joinpath(blinkPkg, "res"))
-L $(joinpath(httpParserPkg, "deps/usr/lib/libhttp_parser.dylib"))
-L $(joinpath(mbedTLSPkg, "deps/usr/lib/libmbedcrypto.2.7.1.dylib"))
$examples_blink "HelloBlink" $builddir`),
"Done building")

@test isdir("$builddir/HelloBlink.app")

# Manually kill HelloBlink, since it waits for user input.
@async begin
sleep(15) # wait til blink has started up
run(`pkill blink`)
end
try # expect failure due to pkill, so not really much to test.
run(`$builddir/HelloBlink.app/Contents/MacOS/blink`)
end

@test success(`./builddir/HelloBlink.app/Contents/MacOS/blink`)
end