Skip to content

Add MOI versions to tests #2689

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

Closed
DimitriAlston opened this issue Mar 11, 2025 · 3 comments · Fixed by #2691
Closed

Add MOI versions to tests #2689

DimitriAlston opened this issue Mar 11, 2025 · 3 comments · Fixed by #2691

Comments

@DimitriAlston
Copy link

The exclude_tests_after argument in runtests does not seem to have any impact on which tests are excluded. When using MathOptInterface.Test.version_added, all of the functions I checked return v0.10.5.

For example,

julia> MathOptInterface.Test.version_added(MathOptInterface.Test.test_nonlinear_constraint_log)
v"0.10.5"

but this test was added in v1.37.2.

@odow
Copy link
Member

odow commented Mar 11, 2025

Yeah I realized that I stopped updating these. There are a few to fix.

@odow
Copy link
Member

odow commented Mar 11, 2025

function tests_by_version(version)
    root = "/Users/Oscar/.julia/dev/MathOptInterface"
    dir = pwd()
    cd(root)
    run(`git checkout v$version`)
    tests = String[]
    regex = r"function (test_[a-zA-Z0-9\_]+)\("
    function version_added_regex(name)
        return Regex("version_added\\(\\s*?::typeof\\($name\\)")
    end
    for file in readdir(joinpath(root, "src", "Test"); join = true)
        contents = read(file, String)
        for index in findall(regex, contents)
            m = match(regex, contents[index])
            if match(version_added_regex(m[1]), contents) === nothing
                push!(tests,  m[1])
            end
        end
    end
    run(`git checkout master`)
    cd(dir)
    return tests
end

tags = split(
    sprint(io -> run(pipeline(`git tag -l`; stdout = io))),
    "\n";
    keepempty = false,
) .|> VersionNumber |> sort!
filter!(v -> v >= v"1", tags)

tests = [tag => tests_by_version(tag) for tag in tags]

tests_added_by_tag = Dict{VersionNumber,Vector{String}}()
for i in 2:length(tests)
    tag, list_of_tests = tests[i]
    new_tests = setdiff(list_of_tests, tests[i-1][2])
    if !isempty(new_tests)
        tests_added_by_tag[tag] = new_tests
    end
end

for tag in sort(collect(keys(tests_added_by_tag)))
    println(tag)
    for l in tests_added_by_tag[tag]
        println("  ", l)
    end
end
1.4.0
  test_cpsat_AllDifferent
  test_cpsat_CountDistinct
  test_cpsat_CountBelongs
  test_cpsat_CountAtLeast
  test_cpsat_CountGreaterThan
  test_cpsat_BinPacking
  test_cpsat_Cumulative
  test_cpsat_Table
  test_cpsat_Circuit
  test_cpsat_Path
1.7.0
  test_attribute_AbsoluteGapTolerance
  test_attribute_RelativeGapTolerance
1.9.0
  test_attribute_unsupported_constraint
1.12.0
  test_multiobjective_vector_of_variables
  test_multiobjective_vector_of_variables_delete
  test_multiobjective_vector_of_variables_delete_all
  test_multiobjective_vector_of_variables_delete_vector
  test_multiobjective_vector_affine_function
  test_multiobjective_vector_affine_function_modify
  test_multiobjective_vector_affine_function_delete
  test_multiobjective_vector_affine_function_delete_vector
  test_multiobjective_vector_quadratic_function
  test_multiobjective_vector_quadratic_function_modify
  test_multiobjective_vector_quadratic_function_delete
  test_multiobjective_vector_quadratic_function_delete_vector
  test_objective_ObjectiveSense_in_ListOfModelAttributesSet
  test_objective_VariableIndex_in_ListOfModelAttributesSet
  test_objective_ScalarAffineFunction_in_ListOfModelAttributesSet
  test_objective_ScalarQuadraticFunction_in_ListOfModelAttributesSet
1.13.0
  test_add_parameter
1.16.0
  test_conic_ScaledPositiveSemidefiniteConeTriangle_VectorAffineFunction
1.17.0
  test_nonlinear_expression_hs071
  test_nonlinear_expression_hs071_epigraph
  test_nonlinear_expression_hs109
  test_nonlinear_expression_hs110
  test_nonlinear_expression_quartic
  test_nonlinear_expression_overrides_objective
  test_nonlinear_expression_univariate_function
  test_nonlinear_expression_multivariate_function
  test_nonlinear_duals
  test_NormSpectralCone_VectorOfVariables_without_transform
  test_NormSpectralCone_VectorOfVariables_with_transform
  test_NormSpectralCone_VectorAffineFunction_without_transform
  test_NormSpectralCone_VectorAffineFunction_with_transform
  test_NormNuclearCone_VectorOfVariables_without_transform
  test_NormNuclearCone_VectorOfVariables_with_transform
  test_NormNuclearCone_VectorAffineFunction_without_transform
  test_NormNuclearCone_VectorAffineFunction_with_transform
  test_HermitianPSDCone_basic
  test_HermitianPSDCone_min_t
1.19.0
  test_multiobjective_vector_nonlinear
  test_multiobjective_vector_nonlinear_delete
  test_multiobjective_vector_nonlinear_delete_vector
  test_multiobjective_vector_nonlinear_modify
  test_nonlinear_vector_complements
1.20.0
  test_attribute_ObjectiveLimit
1.21.0
  test_attribute_SolutionLimit
  test_modification_objective_scalarquadraticcoefficientchange
  test_modification_constraint_scalarquadraticcoefficientchange
1.22.0
  test_model_ListOfVariablesWithAttributeSet
  test_model_ListOfConstraintsWithAttributeSet
1.28.0
  test_modification_mathoptinterface_issue_2452
1.31.0
  test_model_show
1.32.0
  test_attribute_NodeLimit
1.34.0
  test_model_add_constrained_variable_tuple
1.35.0
  test_conic_PositiveSemidefiniteConeTriangle_4
  test_nonlinear_with_scalar_quadratic_function_with_off_diag
  test_nonlinear_constraint_log
  test_nonlinear_constraint_uminus
  test_nonlinear_constraint_scalar_affine_function
  test_nonlinear_quadratic_1
  test_nonlinear_quadratic_2
  test_nonlinear_quadratic_3
  test_nonlinear_quadratic_4
  test_DualObjectiveValue_Min_VariableIndex_GreaterThan
  test_DualObjectiveValue_Max_VariableIndex_LessThan
  test_DualObjectiveValue_Min_ScalarAffine_GreaterThan
  test_DualObjectiveValue_Max_ScalarAffine_LessThan

@odow
Copy link
Member

odow commented Mar 11, 2025

function version_added_latest()
    root = "/Users/Oscar/.julia/dev/MathOptInterface"
    dir = pwd()
    cd(root)
    tests = String[]
    regex = r"version_added\(\s*?::typeof\((.+?)\)"
    for file in readdir(joinpath(root, "src", "Test"); join = true)
        contents = read(file, String)
        for index in findall(regex, contents)
            m = match(regex, contents[index])
            push!(tests, m[1])
        end
    end
    cd(dir)
    return tests
end

functions_with_version_added = version_added_latest()
for tag in sort(collect(keys(tests_added_by_tag)))
    println(tag)
    for l in tests_added_by_tag[tag]
        if !(l in functions_with_version_added)
            println("version_added(::typeof($l)) = v\"$tag\"")
        end
    end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants