Skip to content
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
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ JET = "0.9, 0.10, 0.11"
JSON3 = "1"
JuliaFormatter = "2"
LocalRegistry = "0.5"
SafeTestsets = "0.0.1, 0.1, 1"
SciMLTesting = "1"
SnoopCompileCore = "3"
Statistics = "1"
TOML = "1"
Expand All @@ -37,7 +39,9 @@ julia = "1.10"

[extras]
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["JET", "Test"]
test = ["JET", "SafeTestsets", "SciMLTesting", "Test"]
126 changes: 126 additions & 0 deletions test/core_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using OrgMaintenanceScripts
using Test
using TOML

@testset "OrgMaintenanceScripts.jl" begin
@testset "Version bumping" begin
# Test bump_minor_version
@test OrgMaintenanceScripts.bump_minor_version("1.2.3") == "1.3.0"
@test OrgMaintenanceScripts.bump_minor_version("0.1.0") == "0.2.0"
@test OrgMaintenanceScripts.bump_minor_version("2.10.5") == "2.11.0"

# Test invalid version format
@test_throws ErrorException OrgMaintenanceScripts.bump_minor_version("1.2")
@test_throws ErrorException OrgMaintenanceScripts.bump_minor_version("1.2.3.4")
end

@testset "Project file handling" begin
# Create a temporary test project
mktempdir() do tmpdir
project_path = joinpath(tmpdir, "Project.toml")

# Test with valid Project.toml
project_data = Dict(
"name" => "TestPackage",
"uuid" => "12345678-1234-1234-1234-123456789012",
"version" => "0.1.0"
)

open(project_path, "w") do io
TOML.print(io, project_data)
end

result = OrgMaintenanceScripts.update_project_version(project_path)
@test !isnothing(result)
@test result[1] == "0.1.0"
@test result[2] == "0.2.0"

# Verify file was updated
updated_project = TOML.parsefile(project_path)
@test updated_project["version"] == "0.2.0"

# Test with missing version field
delete!(updated_project, "version")
open(project_path, "w") do io
TOML.print(io, updated_project)
end

result = OrgMaintenanceScripts.update_project_version(project_path)
@test isnothing(result)

# Test with non-existent file
result = OrgMaintenanceScripts.update_project_version(joinpath(tmpdir, "nonexistent.toml"))
@test isnothing(result)
end
end

@testset "Repository processing" begin
# Create a mock repository structure
mktempdir() do tmpdir
# Main Project.toml
main_project = Dict(
"name" => "MainPackage",
"uuid" => "12345678-1234-1234-1234-123456789012",
"version" => "1.0.0"
)
open(joinpath(tmpdir, "Project.toml"), "w") do io
TOML.print(io, main_project)
end

# Create lib directory with subpackages
lib_dir = joinpath(tmpdir, "lib")
mkpath(lib_dir)

for (i, pkg) in enumerate(["SubPkgA", "SubPkgB"])
pkg_dir = joinpath(lib_dir, pkg)
mkpath(pkg_dir)

sub_project = Dict(
"name" => pkg,
"uuid" => "12345678-1234-1234-1234-12345678901$i",
"version" => "0.$i.0"
)
open(joinpath(pkg_dir, "Project.toml"), "w") do io
TOML.print(io, sub_project)
end
end

# Initialize git repo
cd(tmpdir) do
run(`git init`)
run(`git config user.name "Test User"`)
run(`git config user.email "test@example.com"`)
run(`git add .`)
run(`git commit -m "Initial commit"`)
end

# Test bump_and_register_repo
result = bump_and_register_repo(tmpdir)

@test !isnothing(result)
# In test environment, registration will fail since there's no real registry
# So we expect all packages to be in the failed list
@test basename(tmpdir) in result.failed || basename(tmpdir) in result.registered
@test "SubPkgA" in result.failed || "SubPkgA" in result.registered
@test "SubPkgB" in result.failed || "SubPkgB" in result.registered
# Either all succeed or all fail (in tests, they'll all fail)
@test isempty(result.registered) || isempty(result.failed)

# Verify versions were bumped
main_updated = TOML.parsefile(joinpath(tmpdir, "Project.toml"))
@test main_updated["version"] == "1.1.0"

subA_updated = TOML.parsefile(joinpath(lib_dir, "SubPkgA", "Project.toml"))
@test subA_updated["version"] == "0.2.0"

subB_updated = TOML.parsefile(joinpath(lib_dir, "SubPkgB", "Project.toml"))
@test subB_updated["version"] == "0.3.0"
end
end

@testset "Basic functionality (legacy)" begin
# Test deprecated functions still exist but warn
@test_logs (:warn,) OrgMaintenanceScripts.update_manifests()
@test_logs (:warn,) OrgMaintenanceScripts.update_project_tomls()
end
end
3 changes: 2 additions & 1 deletion test/documentation_cleanup_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Note: OrgMaintenanceScripts is already loaded by runtests.jl
using OrgMaintenanceScripts
using Test

@testset "Documentation Cleanup Tests" begin

Expand Down
4 changes: 3 additions & 1 deletion test/explicit_imports_fixer_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Note: OrgMaintenanceScripts is already loaded by runtests.jl
using OrgMaintenanceScripts
using Test
using TOML

@testset "Explicit Imports Fixer" begin
@testset "parse_explicit_imports_output" begin
Expand Down
3 changes: 2 additions & 1 deletion test/formatting_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Note: OrgMaintenanceScripts is already loaded by runtests.jl
using OrgMaintenanceScripts
using Test
using Pkg

@testset "Formatting Functions" begin
Expand Down
3 changes: 2 additions & 1 deletion test/import_timing_analysis_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Note: OrgMaintenanceScripts is already loaded by runtests.jl
using OrgMaintenanceScripts
using Test

@testset "Import Timing Analysis Tests" begin
# Create a simple test package structure
Expand Down
3 changes: 2 additions & 1 deletion test/invalidation_analysis_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Note: OrgMaintenanceScripts is already loaded by runtests.jl
using OrgMaintenanceScripts
using Test

@testset "Invalidation Analysis Tests" begin
# Create a simple test package structure
Expand Down
3 changes: 2 additions & 1 deletion test/min_version_fixer_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Note: OrgMaintenanceScripts is already loaded by runtests.jl
using OrgMaintenanceScripts
using Test

@testset "Minimum Version Fixer Tests" begin
# Test helper functions
Expand Down
10 changes: 7 additions & 3 deletions test/qa/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
OrgMaintenanceScripts = "87d49508-7ad8-40c6-ae47-b3ac92269cd4"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
OrgMaintenanceScripts = {path = "../.."}

[compat]
Aqua = "0.8"
JET = "0.9, 0.10, 0.11"
SafeTestsets = "0.0.1, 0.1, 1"
SciMLTesting = "1"
Test = "1"
julia = "1.10"

[sources]
OrgMaintenanceScripts = {path = "../.."}
File renamed without changes.
152 changes: 2 additions & 150 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,150 +1,2 @@
using Pkg
using OrgMaintenanceScripts
using Test
using TOML
using Dates

const GROUP = get(ENV, "GROUP", "All")

if GROUP == "QA"
Pkg.activate(joinpath(@__DIR__, "qa"))
Pkg.develop(PackageSpec(path = joinpath(@__DIR__, "..")))
Pkg.instantiate()
include("qa.jl")
end

if GROUP == "All" || GROUP == "Core"
@testset "OrgMaintenanceScripts.jl" begin
@testset "Version bumping" begin
# Test bump_minor_version
@test OrgMaintenanceScripts.bump_minor_version("1.2.3") == "1.3.0"
@test OrgMaintenanceScripts.bump_minor_version("0.1.0") == "0.2.0"
@test OrgMaintenanceScripts.bump_minor_version("2.10.5") == "2.11.0"

# Test invalid version format
@test_throws ErrorException OrgMaintenanceScripts.bump_minor_version("1.2")
@test_throws ErrorException OrgMaintenanceScripts.bump_minor_version("1.2.3.4")
end

@testset "Project file handling" begin
# Create a temporary test project
mktempdir() do tmpdir
project_path = joinpath(tmpdir, "Project.toml")

# Test with valid Project.toml
project_data = Dict(
"name" => "TestPackage",
"uuid" => "12345678-1234-1234-1234-123456789012",
"version" => "0.1.0"
)

open(project_path, "w") do io
TOML.print(io, project_data)
end

result = OrgMaintenanceScripts.update_project_version(project_path)
@test !isnothing(result)
@test result[1] == "0.1.0"
@test result[2] == "0.2.0"

# Verify file was updated
updated_project = TOML.parsefile(project_path)
@test updated_project["version"] == "0.2.0"

# Test with missing version field
delete!(updated_project, "version")
open(project_path, "w") do io
TOML.print(io, updated_project)
end

result = OrgMaintenanceScripts.update_project_version(project_path)
@test isnothing(result)

# Test with non-existent file
result = OrgMaintenanceScripts.update_project_version(joinpath(tmpdir, "nonexistent.toml"))
@test isnothing(result)
end
end

@testset "Repository processing" begin
# Create a mock repository structure
mktempdir() do tmpdir
# Main Project.toml
main_project = Dict(
"name" => "MainPackage",
"uuid" => "12345678-1234-1234-1234-123456789012",
"version" => "1.0.0"
)
open(joinpath(tmpdir, "Project.toml"), "w") do io
TOML.print(io, main_project)
end

# Create lib directory with subpackages
lib_dir = joinpath(tmpdir, "lib")
mkpath(lib_dir)

for (i, pkg) in enumerate(["SubPkgA", "SubPkgB"])
pkg_dir = joinpath(lib_dir, pkg)
mkpath(pkg_dir)

sub_project = Dict(
"name" => pkg,
"uuid" => "12345678-1234-1234-1234-12345678901$i",
"version" => "0.$i.0"
)
open(joinpath(pkg_dir, "Project.toml"), "w") do io
TOML.print(io, sub_project)
end
end

# Initialize git repo
cd(tmpdir) do
run(`git init`)
run(`git config user.name "Test User"`)
run(`git config user.email "test@example.com"`)
run(`git add .`)
run(`git commit -m "Initial commit"`)
end

# Test bump_and_register_repo
result = bump_and_register_repo(tmpdir)

@test !isnothing(result)
# In test environment, registration will fail since there's no real registry
# So we expect all packages to be in the failed list
@test basename(tmpdir) in result.failed || basename(tmpdir) in result.registered
@test "SubPkgA" in result.failed || "SubPkgA" in result.registered
@test "SubPkgB" in result.failed || "SubPkgB" in result.registered
# Either all succeed or all fail (in tests, they'll all fail)
@test isempty(result.registered) || isempty(result.failed)

# Verify versions were bumped
main_updated = TOML.parsefile(joinpath(tmpdir, "Project.toml"))
@test main_updated["version"] == "1.1.0"

subA_updated = TOML.parsefile(joinpath(lib_dir, "SubPkgA", "Project.toml"))
@test subA_updated["version"] == "0.2.0"

subB_updated = TOML.parsefile(joinpath(lib_dir, "SubPkgB", "Project.toml"))
@test subB_updated["version"] == "0.3.0"
end
end

@testset "Basic functionality (legacy)" begin
# Test deprecated functions still exist but warn
@test_logs (:warn,) OrgMaintenanceScripts.update_manifests()
@test_logs (:warn,) OrgMaintenanceScripts.update_project_tomls()
end

include("formatting_tests.jl")
include("min_version_fixer_tests.jl")
include("version_check_finder_tests.jl")
include("invalidation_analysis_tests.jl")
include("import_timing_analysis_tests.jl")
include("explicit_imports_fixer_tests.jl")
# Temporarily commented out due to syntax error in multiprocess_testing.jl
# include("multiprocess_testing_tests.jl")
include("documentation_cleanup_tests.jl")
# JET/Aqua static analysis runs in the QA group (GROUP=QA -> test/qa.jl).
end
end
using SciMLTesting
run_tests()
3 changes: 2 additions & 1 deletion test/version_check_finder_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Note: OrgMaintenanceScripts is already loaded by runtests.jl
using OrgMaintenanceScripts
using Test

@testset "Version Check Finder Tests" begin
# Create temporary test files
Expand Down
Loading