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

Separate out the build files for each example. #14

Merged
merged 2 commits into from
Jul 20, 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
45 changes: 17 additions & 28 deletions test/BuildApp.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using Base.Test
using ApplicationBuilder; using BuildApp;

examples_blink = joinpath(@__DIR__, "..", "examples", "blink.jl")
examples_hello = joinpath(@__DIR__, "..", "examples", "hello.jl")

builddir = mktempdir()
@assert isdir(builddir)

@testset "HelloWorld.app" begin
@test 0 == BuildApp.build_app_bundle(examples_hello;
verbose=true, appname="HelloWorld", builddir=builddir)
@test 0 == include("build_examples/hello.jl")
@test isdir("$builddir/HelloWorld.app")
@test success(`$builddir/HelloWorld.app/Contents/MacOS/hello`)

Expand All @@ -25,33 +21,26 @@ builddir = mktempdir()
end
end


function testRunAndKillProgramSucceeds(cmd)
out, _, p = readandwrite(cmd) # Make sure it runs correctly
sleep(1)
process_exited(p) && (println("Test Failed: failed to launch: \n", readstring(out)); return false)
sleep(10)
process_exited(p) && (println("Test Failed: Process died: \n", readstring(out)); return false)
# Manually kill program after it's been running for a bit.
kill(p); sleep(1)
process_exited(p) || (println("Test Failed: Process failed to exit: \n", readstring(out)); return false)
return true
end

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

@test 0 == BuildApp.build_app_bundle(examples_blink;
verbose = true,
resources = [joinpath(blinkPkg, "deps","Julia.app"),
joinpath(blinkPkg, "src","AtomShell","main.js"),
joinpath(blinkPkg, "src","content","main.html"),
joinpath(blinkPkg, "res")],
libraries = [joinpath(httpParserPkg, "deps","usr","lib","libhttp_parser.dylib"),
joinpath(mbedTLSPkg, "deps","usr","lib","libmbedcrypto.2.dylib")],
appname="HelloBlink", builddir=builddir)
@test 0 == include("build_examples/blink.jl")

@test isdir("$builddir/HelloBlink.app")
# Test that it copied the correct files
@test isdir("$builddir/HelloBlink.app/Contents/Libraries")
@test isfile("$builddir/HelloBlink.app/Contents/Resources/main.js")

# 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 that it runs correctly
@test testRunAndKillProgramSucceeds(`$builddir/HelloBlink.app/Contents/MacOS/blink`)
end
27 changes: 27 additions & 0 deletions test/build_examples/blink.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using ApplicationBuilder; using BuildApp

examples_blink = joinpath(@__DIR__, "..", "..", "examples", "blink.jl")

# Allow this file to be called either as a standalone file to build the above
# example, or from runtests.jl using a provided builddir.
isdefined(:builddir) || (builddir=mktempdir())

blinkPkg = Pkg.dir("Blink")
httpParserPkg = Pkg.dir("HttpParser")
mbedTLSPkg = Pkg.dir("MbedTLS")

@assert blinkPkg != nothing "Blink is not installed!"

using Blink

BuildApp.build_app_bundle(examples_blink;
verbose = true,
resources = [joinpath(blinkPkg, "deps","Julia.app"),
joinpath(blinkPkg, "src","AtomShell","main.js"),
joinpath(blinkPkg, "src","content","main.html"),
joinpath(blinkPkg, "res")],
# Get the current library names directly from the packages that use them,
# which keeps this build script robust against lib version changes.
libraries = [HttpParser.lib,
MbedTLS.libmbedcrypto],
appname="HelloBlink", builddir=builddir)
10 changes: 10 additions & 0 deletions test/build_examples/hello.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using ApplicationBuilder; using BuildApp

examples_hello = joinpath(@__DIR__, "..", "..", "examples", "hello.jl")

# Allow this file to be called either as a standalone file to build the above
# example, or from runtests.jl using a provided builddir.
isdefined(:builddir) || (builddir=mktempdir())

BuildApp.build_app_bundle(examples_hello;
verbose=true, appname="HelloWorld", builddir=builddir)