1
1
using Base. Test
2
2
using ApplicationBuilder; using BuildApp;
3
3
4
- examples_blink = joinpath (@__DIR__ , " .." , " examples" , " blink.jl" )
5
- examples_hello = joinpath (@__DIR__ , " .." , " examples" , " hello.jl" )
6
-
7
4
builddir = mktempdir ()
8
5
@assert isdir (builddir)
9
6
10
7
@testset " HelloWorld.app" begin
11
- @test 0 == BuildApp. build_app_bundle (examples_hello;
12
- verbose= true , appname= " HelloWorld" , builddir= builddir)
8
+ @test 0 == include (" build_examples/hello.jl" )
13
9
@test isdir (" $builddir /HelloWorld.app" )
14
10
@test success (` $builddir /HelloWorld.app/Contents/MacOS/hello` )
15
11
@@ -25,33 +21,26 @@ builddir = mktempdir()
25
21
end
26
22
end
27
23
24
+
25
+ function testRunAndKillProgramSucceeds (cmd)
26
+ out, _, p = readandwrite (cmd) # Make sure it runs correctly
27
+ sleep (1 )
28
+ process_exited (p) && (println (" Test Failed: failed to launch: \n " , readstring (out)); return false )
29
+ sleep (10 )
30
+ process_exited (p) && (println (" Test Failed: Process died: \n " , readstring (out)); return false )
31
+ # Manually kill program after it's been running for a bit.
32
+ kill (p); sleep (1 )
33
+ process_exited (p) || (println (" Test Failed: Process failed to exit: \n " , readstring (out)); return false )
34
+ return true
35
+ end
36
+
28
37
@testset " HelloBlink.app" begin
29
- blinkPkg = Pkg. dir (" Blink" )
30
- httpParserPkg = Pkg. dir (" HttpParser" )
31
- mbedTLSPkg = Pkg. dir (" MbedTLS" )
32
-
33
- @test 0 == BuildApp. build_app_bundle (examples_blink;
34
- verbose = true ,
35
- resources = [joinpath (blinkPkg, " deps" ," Julia.app" ),
36
- joinpath (blinkPkg, " src" ," AtomShell" ," main.js" ),
37
- joinpath (blinkPkg, " src" ," content" ," main.html" ),
38
- joinpath (blinkPkg, " res" )],
39
- libraries = [joinpath (httpParserPkg, " deps" ," usr" ," lib" ," libhttp_parser.dylib" ),
40
- joinpath (mbedTLSPkg, " deps" ," usr" ," lib" ," libmbedcrypto.2.dylib" )],
41
- appname= " HelloBlink" , builddir= builddir)
38
+ @test 0 == include (" build_examples/blink.jl" )
42
39
43
40
@test isdir (" $builddir /HelloBlink.app" )
44
41
# Test that it copied the correct files
45
42
@test isdir (" $builddir /HelloBlink.app/Contents/Libraries" )
46
43
@test isfile (" $builddir /HelloBlink.app/Contents/Resources/main.js" )
47
-
48
- # Manually kill HelloBlink, since it waits for user input.
49
- @async begin
50
- sleep (15 ) # wait til blink has started up
51
- run (` pkill blink` )
52
- end
53
- try # expect failure due to pkill, so not really much to test.
54
- run (` $builddir /HelloBlink.app/Contents/MacOS/blink` )
55
- end
56
-
44
+ # Test that it runs correctly
45
+ @test testRunAndKillProgramSucceeds (` $builddir /HelloBlink.app/Contents/MacOS/blink` )
57
46
end
0 commit comments