Skip to content

Commit

Permalink
test: cleanup tests and avoid interference
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jul 9, 2024
1 parent f6f9687 commit ea6ccce
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 39 deletions.
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ LuxDeviceUtilsZygoteExt = "Zygote"
LuxDeviceUtilsoneAPIExt = ["GPUArrays", "oneAPI"]

[compat]
AMDGPU = "0.8.4, 0.9"
AMDGPU = "0.9.6"
Adapt = "4"
Aqua = "0.8.4"
ArrayInterface = "7.11"
CUDA = "5.2"
ChainRulesCore = "1.23"
ChainRulesTestUtils = "1.13.0"
ComponentArrays = "0.15.8"
ExplicitImports = "1.4.1"
ExplicitImports = "1.9.0"
FillArrays = "1"
ForwardDiff = "0.10.36"
Functors = "0.4.4"
Expand All @@ -64,7 +64,6 @@ ReverseDiff = "1.15"
SafeTestsets = "0.1"
SparseArrays = "1.10"
Test = "1.10"
TestSetExtensions = "3"
Tracker = "0.2.34"
Zygote = "0.6.69"
julia = "1.10"
Expand All @@ -86,9 +85,8 @@ ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04"
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Aqua", "ArrayInterface", "ChainRulesTestUtils", "ComponentArrays", "ExplicitImports", "FillArrays", "ForwardDiff", "LuxCore", "Pkg", "Random", "RecursiveArrayTools", "ReverseDiff", "SafeTestsets", "SparseArrays", "Test", "TestSetExtensions", "Tracker", "Zygote"]
test = ["Aqua", "ArrayInterface", "ChainRulesTestUtils", "ComponentArrays", "ExplicitImports", "FillArrays", "ForwardDiff", "LuxCore", "Pkg", "Random", "RecursiveArrayTools", "ReverseDiff", "SafeTestsets", "SparseArrays", "Test", "Tracker", "Zygote"]
2 changes: 1 addition & 1 deletion test/amdgpu.jl → test/amdgpu_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LuxDeviceUtils, Random
using LuxDeviceUtils, Random, Test
using ArrayInterface: parameterless_type

@testset "CPU Fallback" begin
Expand Down
2 changes: 1 addition & 1 deletion test/cuda.jl → test/cuda_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LuxDeviceUtils, Random, Functors
using LuxDeviceUtils, Random, Functors, Test
using ArrayInterface: parameterless_type

@testset "CPU Fallback" begin
Expand Down
6 changes: 0 additions & 6 deletions test/explicit_imports.jl

This file was deleted.

2 changes: 1 addition & 1 deletion test/metal.jl → test/metal_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LuxDeviceUtils, Random
using LuxDeviceUtils, Random, Test

@testset "CPU Fallback" begin
@test !LuxDeviceUtils.functional(LuxMetalDevice)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/oneapi.jl → test/oneapi_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LuxDeviceUtils, Random
using LuxDeviceUtils, Random, Test

@testset "CPU Fallback" begin
@test !LuxDeviceUtils.functional(LuxoneAPIDevice)
Expand Down
17 changes: 17 additions & 0 deletions test/qa_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Aqua, LuxDeviceUtils, Test

@testset "Aqua Tests" begin
Aqua.test_all(LuxDeviceUtils)
end

import FillArrays, RecursiveArrayTools, SparseArrays, Zygote

@testset "Explicit Imports" begin
@test check_no_implicit_imports(LuxDeviceUtils) === nothing
@test check_no_stale_explicit_imports(LuxDeviceUtils) === nothing
@test check_no_self_qualified_accesses(LuxDeviceUtils) === nothing
@test check_all_explicit_imports_via_owners(LuxDeviceUtils) === nothing
@test check_all_qualified_accesses_via_owners(LuxDeviceUtils) === nothing
@test_broken check_all_explicit_imports_are_public(LuxDeviceUtils) === nothing # mostly upstream problems
@test_broken check_all_qualified_accesses_are_public(LuxDeviceUtils) === nothing # mostly upstream problem
end
48 changes: 24 additions & 24 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import Pkg
using Aqua, SafeTestsets, Test, LuxDeviceUtils, TestSetExtensions
using SafeTestsets, Test

const BACKEND_GROUP = get(ENV, "BACKEND_GROUP", "NONE")
const BACKEND_GROUP = lowercase(get(ENV, "BACKEND_GROUP", "NONE"))

@testset ExtendedTestSet "LuxDeviceUtils Tests" begin
if BACKEND_GROUP == "CUDA" || BACKEND_GROUP == "ALL"
Pkg.add("LuxCUDA")
@safetestset "CUDA" include("cuda.jl")
end
const EXTRA_PKGS = String[]

if BACKEND_GROUP == "AMDGPU" || BACKEND_GROUP == "ALL"
Pkg.add("AMDGPU")
@safetestset "AMDGPU" include("amdgpu.jl")
end
(BACKEND_GROUP == "all" || BACKEND_GROUP == "cuda") && push!(EXTRA_PKGS, "LuxCUDA")
(BACKEND_GROUP == "all" || BACKEND_GROUP == "amdgpu") && push!(EXTRA_PKGS, "AMDGPU")
(BACKEND_GROUP == "all" || BACKEND_GROUP == "oneapi") && push!(EXTRA_PKGS, "oneAPI")
(BACKEND_GROUP == "all" || BACKEND_GROUP == "metal") && push!(EXTRA_PKGS, "Metal")

if BACKEND_GROUP == "Metal" || BACKEND_GROUP == "ALL"
Pkg.add("Metal")
@safetestset "Metal" include("metal.jl")
end
if !isempty(EXTRA_PKGS)
@info "Installing Extra Packages for testing" EXTRA_PKGS=EXTRA_PKGS
Pkg.add(EXTRA_PKGS)
Pkg.update()
Base.retry_load_extensions()
Pkg.instantiate()
end

if BACKEND_GROUP == "oneAPI" || BACKEND_GROUP == "ALL"
Pkg.add("oneAPI")
@safetestset "oneAPI" include("oneapi.jl")
@testset "LuxDeviceUtils Tests" begin
file_names = BACKEND_GROUP == "all" ?
["cuda_tests.jl", "amdgpu_tests.jl", "metal_tests.jl", "oneapi_tests.jl"] :
[BACKEND_GROUP * "_tests.jl"]
@testset "$(file_name)" for file_name in file_names
run(`$(Base.julia_cmd()) --color=yes --project=$(dirname(Pkg.project().path))
--startup-file=no --code-coverage=user $(@__DIR__)/$file_name`)
Test.@test true
end

@testset "Others" begin
@testset "Aqua Tests" Aqua.test_all(LuxDeviceUtils)

@safetestset "Misc Tests" include("misc.jl")
@safetestset "Misc Tests" include("misc_tests.jl")

@safetestset "Explicit Imports" include("explicit_imports.jl")
end
@safetestset "QA Tests" include("qa_tests.jl")
end

0 comments on commit ea6ccce

Please sign in to comment.