@@ -3,6 +3,7 @@ using Test
33using Libdl
44using Pkg
55
6+ import GNUMake_jll
67import TOML
78
89ENV [" JULIA_DEBUG" ] = " PackageCompiler"
242243 hello = read (` $(Base. julia_cmd ()) -J $(sysimage_path) -e 'print("hello, world")'` , String)
243244 @test hello == " hello, world"
244245 end
245- end
246+
247+ @testset " examples/MyLib" begin
248+ # This testset makes sure that the `examples/MyLib` example does not bitrot.
249+
250+ if Sys. iswindows ()
251+ @info " Skipping the examples/MyLib test on Windows"
252+ @test_skip false
253+ # TODO : Figure out how to get this testset to work on Windows.
254+ else
255+ rootdir_testdir = @__DIR__
256+ rootdir = dirname (rootdir_testdir)
257+ rootdir_examples = joinpath (rootdir, " examples" )
258+ rootdir_examples_MyLib = joinpath (rootdir_examples, " MyLib" )
259+
260+ my_run = (cmd:: Cmd ) -> begin
261+ env2 = copy (ENV )
262+
263+ # The `JULIA` environment variable is used by our `MyLib/Makefile`.
264+ # The `GCC` environment variable is used by our `MyLib/Makefile`.
265+ env2[" JULIA" ] = Base. julia_cmd ()[1 ]
266+ env2[" GCC" ] = PackageCompiler. get_compiler_cmd ()[1 ]
267+
268+ return run (cmd)
269+ end
270+
271+ cd (rootdir_examples_MyLib) do
272+ # We need to go into examples/MyLib/build/ and dev this copy of PackageCompiler.jl
273+ code = """
274+ import Pkg
275+ Pkg.develop(;path = "$(rootdir) ")
276+ """
277+ cmd = ` $(Base. julia_cmd ()[1 ]) --project="./build" -e "$(code) "`
278+ run (cmd)
279+
280+
281+ # We don't want to assume that the machine running the tests has `make` installed
282+ # and available in the PATH. Therefore, we use the `GNUMake_jll.jl`` package.
283+ my_run (` $(GNUMake_jll. make ()) ` )
284+
285+ env2 = copy (ENV )
286+ if Sys. isapple ()
287+ env2[" DYLD_FALLBACK_LIBRARY_PATH" ] = " ./MyLibCompiled/lib/:./MyLibCompiled/lib/julia"
288+ else
289+ # env2["LD_LIBRARY_PATH"] = "./MyLibCompiled/lib/:./MyLibCompiled/lib/julia"
290+ env2[" LD_LIBRARY_PATH" ] = " ./MyLibCompiled/lib/"
291+ end
292+ cmd = ` ./my_application.out`
293+ run (setenv (cmd, env2))
294+ observed_str = strip (read (setenv (cmd, env2), String))
295+ expected_str = " Incremented count: 4 (Cint)\n Incremented value: 4"
296+ @test observed_str == expected_str
297+
298+ # Yes, we do have a convenience wrapper script at `examples/MyLib/runme.bash`
299+ # However, for the PackageCompiler test suite, we don't want to make any assumptions
300+ # about Bash being available on the machine that's running the tests.
301+ # So instead, we manaully run the `./my_application.out` executable ourselves.
302+
303+ # Finally, exercise a few more `Makefile` targets, to make sure that they
304+ # don't bitrot.
305+ my_run (` $(GNUMake_jll. make ()) all` )
306+ my_run (` $(GNUMake_jll. make ()) build-library` )
307+ my_run (` $(GNUMake_jll. make ()) build-executable` )
308+ my_run (` $(GNUMake_jll. make ()) clean` )
309+ end # cd
310+ end # if-elseif-else-end
311+ end # testset "examples/MyLib"
312+ end # testset "PackageCompiler.jl"
0 commit comments