Skip to content

bump coverage #1392

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

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
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
46 changes: 28 additions & 18 deletions test/auditing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end
build_path,
"isa_tests",
v"1.0.0",
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
# Build the test suite, install the binaries into our prefix's `bin`
raw"""
cd ${WORKSPACE}/srcdir/isa_tests
Expand Down Expand Up @@ -110,7 +110,7 @@ end
build_path,
"isa_tests",
v"1.0.0",
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
# Build the test suite, install the binaries into our prefix's `bin`
raw"""
cd ${WORKSPACE}/srcdir/isa_tests
Expand Down Expand Up @@ -159,7 +159,7 @@ end
build_path,
"isa_tests",
v"1.0.0",
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
# Build the test suite, install the binaries into our prefix's `bin`
raw"""
cd ${WORKSPACE}/srcdir/isa_tests
Expand Down Expand Up @@ -217,7 +217,7 @@ end
"libcxxstringabi_test",
v"1.0.0",
# Copy in the build_tests sources
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
script,
# Build for this platform
[platform],
Expand Down Expand Up @@ -305,7 +305,7 @@ end
"libfoo",
v"1.0.0",
# Copy in the libfoo sources
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
# Build libfoo using autotools to create a real .la file, and also
# create a fake .la file (which should not be removed). Create also a
# symlink libqux.la -> libfoo.la, which will be broken after libfoo.la
Expand Down Expand Up @@ -348,7 +348,7 @@ end
"libfoo",
v"1.0.0",
# Copy in the libfoo sources
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
libfoo_autotools_script,
# Build for our platform
[platform],
Expand Down Expand Up @@ -527,7 +527,7 @@ end

@testset "Auditor - gcc version" begin
# These tests assume our gcc version is concrete (e.g. that Julia is linked against libgfortran)
our_libgfortran_version = libgfortran_version(platform)
our_libgfortran_version = libgfortran_version(HOST_PLATFORM)
@test our_libgfortran_version != nothing

mktempdir() do build_path
Expand All @@ -547,7 +547,7 @@ end
install_license /usr/share/licenses/libuv/LICENSE
""",
# Build for our platform
[platform],
[HOST_PLATFORM],
#
Product[hello_world],
# Note: we purposefully don't require CompilerSupportLibraries, even if we
Expand All @@ -558,7 +558,7 @@ end
end

# Extract our platform's build, run the hello_world tests:
output_meta = select_platform(build_output_meta, platform)
output_meta = select_platform(build_output_meta, HOST_PLATFORM)
@test output_meta != nothing
tarball_path, tarball_hash = output_meta[1:2]

Expand All @@ -572,23 +572,23 @@ end
unpack(tarball_path, testdir)

# Attempt to run the executable, we expect it to work since it's our platform:
hello_world_path = locate(hello_world, Prefix(testdir); platform=platform)
hello_world_path = locate(hello_world, Prefix(testdir); platform=HOST_PLATFORM)
with_libgfortran() do
@test readchomp(`$hello_world_path`) == "Hello, World!"
end

# If we audit the testdir, pretending that we're trying to build an ABI-agnostic
# tarball, make sure it warns us about it.
@test_logs (:warn, r"links to libgfortran!") match_mode=:any begin
@test !Auditor.audit(Prefix(testdir); platform=BinaryBuilderBase.abi_agnostic(platform), autofix=false)
@test !Auditor.audit(Prefix(testdir); platform=BinaryBuilderBase.abi_agnostic(HOST_PLATFORM), autofix=false)
# Make sure audit is otherwise happy with the executable
# Note by Mosè: this test was introduced before
# https://github.com/JuliaPackaging/BinaryBuilder.jl/pull/1240 and relied on the
# fact audit was ok with not depending on CSL for packages needing GCC
# libraries, but that was a fallacious expectation. At the moment I don't know
# how to meaningfully use this test, leaving here as broken until we come up
# with better ideas (just remove the test?).
@test Auditor.audit(Prefix(testdir); platform=platform, autofix=false) broken=true
@test Auditor.audit(Prefix(testdir); platform=HOST_PLATFORM, autofix=false) broken=true
end

# Let's pretend that we're building for a different libgfortran version:
Expand All @@ -597,7 +597,7 @@ end
other_libgfortran_version = libgfortran_versions[findfirst(v -> v != our_libgfortran_version.major, libgfortran_versions)]
@test_logs (:warn, Regex("but we are supposedly building for libgfortran$(other_libgfortran_version)")) (:warn, r"Linked library libgfortran\.so\.(4|5)") (:warn, r"Linked library libquadmath\.so\.0") (:warn, r"Linked library libgcc_s\.so\.1") readmeta(hello_world_path) do ohs
foreach(ohs) do oh
p = deepcopy(platform)
p = deepcopy(HOST_PLATFORM)
p["libgfortran_version"] = "$(other_libgfortran_version).0.0"
@test !Auditor.audit(Prefix(testdir); platform=p, autofix=false)
end
Expand Down Expand Up @@ -650,7 +650,7 @@ end
end

@testset "Auditor - rpaths" begin
@testset "$platform" for platform in (Platform("x86_64", "linux"; libc="glibc"), Platform("x86_64", "macos"))
@testset "$HOST_PLATFORM" for platform in (Platform("x86_64", "linux"; libc="glibc"), Platform("x86_64", "macos"))
mktempdir() do build_path
build_output_meta = nothing
@test_logs (:info, "Building for $(triplet(platform))") match_mode=:any begin
Expand Down Expand Up @@ -762,7 +762,7 @@ end
chmod 640 "${libdir}/libfoo.${dlext}"
""",
# Build for our platform
[platform],
[HOST_PLATFORM],
# Ensure our library product is built
[product],
# No dependencies
Expand All @@ -773,16 +773,16 @@ end
end

# Extract our platform's build
@test haskey(build_output_meta, platform)
tarball_path, tarball_hash = build_output_meta[platform][1:2]
@test haskey(build_output_meta, HOST_PLATFORM)
tarball_path, tarball_hash = build_output_meta[HOST_PLATFORM][1:2]
@test isfile(tarball_path)

# Unpack it somewhere else
@test verify(tarball_path, tarball_hash)
testdir = joinpath(build_path, "testdir")
mkdir(testdir)
unpack(tarball_path, testdir)
libfoo_path = joinpath(testdir, build_output_meta[platform][4][product]["path"])
libfoo_path = joinpath(testdir, build_output_meta[HOST_PLATFORM][4][product]["path"])
# Tar.jl normalizes permissions of executable files to 0o755, instead of
# recording exact original permissions:
# https://github.com/JuliaIO/Tar.jl/blob/37766a22f5a6ac9f07022d83debd5db7d7a4b896/README.md#permissions
Expand Down Expand Up @@ -994,3 +994,13 @@ end
@test !valid_library_path("/usr/libc.so", macos)
@test !valid_library_path("/usr/libc.so", windows)
end

@testset "platform_for_object" begin
arch_host = arch(HOST_PLATFORM)
bin = Base.julia_cmd().exec |> first
BinaryBuilder.readmeta(bin) do ohs
foreach(ohs) do oh
@test arch(Auditor.platform_for_object(oh)) == arch_host
end
end
end
6 changes: 3 additions & 3 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end
exit 0
""",
# Build for this platform
[platform],
[HOST_PLATFORM],
# No products
Product[],
# No dependencies
Expand All @@ -82,13 +82,13 @@ end
MARKER=1
exit 1
""",
[platform],
[HOST_PLATFORM],
Product[],
Dependency[],
)

# build_path is the nonce'd build directory
build_path = joinpath(temp_path, "build", triplet(platform))
build_path = joinpath(temp_path, "build", triplet(HOST_PLATFORM))
build_path = joinpath(build_path, first(readdir(build_path)))

# Ensure that we get a metadir, and that our history and .env files are in there!
Expand Down
42 changes: 21 additions & 21 deletions test/building.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Copy files in, commit them. This is the commit we will build.
repo = LibGit2.init(git_path)
LibGit2.commit(repo, "Initial empty commit")
libfoo_src_dir = joinpath(build_tests_dir, "libfoo")
libfoo_src_dir = joinpath(BUILD_TESTS_DIR, "libfoo")
run(`cp -r $(libfoo_src_dir)/$(readdir(libfoo_src_dir)) $(git_path)/`)
for file in readdir(git_path)
LibGit2.add!(repo, file)
Expand All @@ -24,7 +24,7 @@
LibGit2.add!(repo, "Makefile")
LibGit2.commit(repo, "Break Makefile")

for source in (DirectorySource(build_tests_dir),
for source in (DirectorySource(BUILD_TESTS_DIR),
GitSource(git_path, bytes2hex(LibGit2.raw(LibGit2.GitHash(commit)))))
build_output_meta = autobuild(
build_path,
Expand All @@ -35,7 +35,7 @@
# Use the particular build script we're interested in
script,
# Build for this platform
[platform],
[HOST_PLATFORM],
# The products we expect to be build
libfoo_products,
# No dependencies
Expand All @@ -46,16 +46,16 @@
verbose=true,
)

@test haskey(build_output_meta, platform)
tarball_path, tarball_hash = build_output_meta[platform][1:2]
@test haskey(build_output_meta, HOST_PLATFORM)
tarball_path, tarball_hash = build_output_meta[HOST_PLATFORM][1:2]

# Ensure the build products were created
@test isfile(tarball_path)

# Ensure that the file contains what we expect
contents = list_tarball_files(tarball_path)
@test "bin/fooifier$(platform_exeext(platform))" in contents
@test "lib/libfoo.$(platform_dlext(platform))" in contents
@test "bin/fooifier$(platform_exeext(HOST_PLATFORM))" in contents
@test "lib/libfoo.$(platform_dlext(HOST_PLATFORM))" in contents

# Unpack it somewhere else
@test verify(tarball_path, tarball_hash)
Expand All @@ -66,8 +66,8 @@

# Ensure we can use it
prefix = Prefix(testdir)
fooifier_path = joinpath(bindir(prefix), "fooifier$(platform_exeext(platform))")
libfoo_path = first(filter(f -> isfile(f), joinpath.(libdirs(prefix), "libfoo.$(platform_dlext(platform))")))
fooifier_path = joinpath(bindir(prefix), "fooifier$(platform_exeext(HOST_PLATFORM))")
libfoo_path = first(filter(f -> isfile(f), joinpath.(libdirs(prefix), "libfoo.$(platform_dlext(HOST_PLATFORM))")))

# We know that foo(a, b) returns 2*a^2 - b
result = 2*2.2^2 - 1.1
Expand Down Expand Up @@ -96,8 +96,8 @@ end
mktempdir() do build_path
name = "libfoo"
build_output_meta = build_tarballs(
["--deploy=local"], name, v"1.0.0", [DirectorySource(build_tests_dir)],
libfoo_make_script, [platform], libfoo_products, Dependency[];
["--deploy=local"], name, v"1.0.0", [DirectorySource(BUILD_TESTS_DIR)],
libfoo_make_script, [HOST_PLATFORM], libfoo_products, Dependency[];
skip_audit = true,
)
artifacts_toml = TOML.parsefile(joinpath(BinaryBuilder.codedir(name), "Artifacts.toml"))
Expand All @@ -118,12 +118,12 @@ end
end
end

shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(platform))
shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(HOST_PLATFORM))
if lowercase(get(ENV, "BINARYBUILDER_FULL_SHARD_TEST", "false")) == "true"
@info("Beginning full shard test... (this can take a while)")
shards_to_test = supported_platforms()
else
shards_to_test = [platform]
shards_to_test = [HOST_PLATFORM]
end

# Expand to all platforms
Expand Down Expand Up @@ -203,7 +203,7 @@ shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(shards_to_test))
@test length(keys(platforms)) == length(keys(build_output_meta))

# Extract our platform's build, run the hello_world tests:
output_meta = select_platform(build_output_meta, platform)
output_meta = select_platform(build_output_meta, HOST_PLATFORM)
if !isnothing(output_meta)
tarball_path, tarball_hash = output_meta[1:2]

Expand Down Expand Up @@ -376,7 +376,7 @@ end
# No sources
FileSource[],
"true",
[HostPlatform()],
[HOST_PLATFORM],
Product[],
# Three dependencies; one good, two bad
[
Expand All @@ -395,7 +395,7 @@ end
v"1.1.1+c",
GitSource[],
"true",
[HostPlatform()],
[HOST_PLATFORM],
Product[],
Dependency[],
)
Expand All @@ -405,7 +405,7 @@ end
v"1.2.3-4",
GitSource[],
"true",
[HostPlatform()],
[HOST_PLATFORM],
Product[],
Dependency[],
)
Expand Down Expand Up @@ -448,7 +448,7 @@ end
build_path,
"libfoo",
v"1.0.0",
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
libfoo_cmake_script,
[AnyPlatform()],
libfoo_products,
Expand Down Expand Up @@ -476,7 +476,7 @@ end
make install
""",
# Build for this platform
[platform],
[HOST_PLATFORM],
# The products we expect to be build
[LibraryProduct("libconfuse", :libconfuse)],
# No dependencies
Expand All @@ -485,7 +485,7 @@ end
skip_audit=true,
)
end
@test haskey(build_output_meta, platform)
@test haskey(build_output_meta, HOST_PLATFORM)
end

@testset "Building framework" begin
Expand All @@ -504,7 +504,7 @@ end
build_path,
"libfoo",
v"1.0.0",
[DirectorySource(build_tests_dir)],
[DirectorySource(BUILD_TESTS_DIR)],
# Build the test suite, install the binaries into our prefix's `bin`
libfoo_cmake_script,
# Build for ALL the platforms
Expand Down
8 changes: 4 additions & 4 deletions test/jll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ end
mktempdir() do build_path
name = "libfoo"
version = v"1.0.0"
sources = [DirectorySource(build_tests_dir)]
sources = [DirectorySource(BUILD_TESTS_DIR)]
# Build for this platform and a platform that isn't this one for sure:
# FreeBSD.
freebsd = Platform("x86_64", "freebsd")
platforms = [platform, freebsd]
platforms = [HOST_PLATFORM, freebsd]
# We depend on Zlib_jll only on the host platform, but not on FreeBSD
dependencies = [
Dependency("Zlib_jll"; platforms=[platform]),
Dependency("Zlib_jll"; platforms=[HOST_PLATFORM]),
RuntimeDependency("Preferences"; top_level=true)
]
# Augment platform
Expand Down Expand Up @@ -205,7 +205,7 @@ end
end
# Make sure we use Zlib_jll only in the wrapper for the host
# platform and not the FreeBSD one.
platform_wrapper = joinpath(code_dir, "src", "wrappers", triplet(platform) * ".jl")
platform_wrapper = joinpath(code_dir, "src", "wrappers", triplet(HOST_PLATFORM) * ".jl")
freebsd_wrapper = joinpath(code_dir, "src", "wrappers", triplet(freebsd) * ".jl")
main_src = joinpath(code_dir, "src", name * "_jll.jl")
@test contains(readchomp(platform_wrapper), "using Zlib_jll")
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ using Random, LibGit2, Test, ObjectFile, SHA, Downloads, TOML
import Libdl

# The platform we're running on
const platform = HostPlatform()
const build_tests_dir = joinpath(@__DIR__, "build_tests")
const HOST_PLATFORM = HostPlatform()
const BUILD_TESTS_DIR = joinpath(@__DIR__, "build_tests")

# Helper function to run fortran code with the path to libgfortran/libquadmath
# embedded in the appropriate environment variables (JLL packages we love you so)
Expand Down
Loading
Loading