-
Notifications
You must be signed in to change notification settings - Fork 87
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
Rewrite MOI.Test #1398
Comments
I had wanted to do a much larger refactoring of the tests, but it seemed like a lot of breakage for little gain... |
There are quite a few test-related issues, and it can be hard to make sure you run all tests. At this point I'd say we have a lot of tests, but they could do with a better organization and structure. And that it would make a big quality of life improvement for developers and solver authors. It's also a lot of effort to add new tests. I wonder about having a single MOI.Test.runtests(
optimizer,
config,
include = [
"test_linear_", # name -> startswith(name, "test_linear_")
],
exclude = [
r"conic", # name -> occursin(name, r"conic")
],
) |
I agree, we could do that if we make the tests automatically exclude themself if what's tested is not supported, instead of testing |
I'm working on a PR that I think makes a lot more sense. Stay tuned. |
@blegat: these MathOptInterface.jl/src/attributes.jl Lines 299 to 308 in fe19bbf
This is causing GLPK to fail the new tests because it doesn't skip unsupported attributes. |
|
I think it only makes sense to define supports for optional attributes. |
I don't thing there is a well-defined notion of core part of the API. Many ModelLike don't implement ListOfModelAttributesSet |
Moving the |
Changing the fallback to throw The work-around would be to change @test MOI.get(model, MOI.SolverName()) isa AbstractString to ret = MOI.get(model, MOI.SolverName())
@test ret isa AbstractString but that's pretty painful and likely to break. The better long-term solution is to move away from |
I don't understand, we would do that right ? if MOI.supports(model, MOI.SolverName())
@test MOI.get(model, MOI.SolverName()) isa AbstractString
end And you want a way to avoid having to write the |
Yeah: @requires MOI.supports(model, MOI.SolverName()) The other approach is that we already catch and pass on Extending |
Okay! That was an ordeal. I'm closing this issue as complete. The "supports" thing is still unresolved, but I might leave it for now and try updating some solvers. We can open a new issue to track if it becomes a problem. |
The test names do not follow the style guide, should we renamecontlineartest
tocontinuous_linear_test
?Edit: @odow: hijacking this issue to lay out my plan for the new MOI.Test
Purpose
The purpose of this issue is to track the items that need to be completed in order to rewrite our MOI.Test submodule.
Significant progress and design was started in #1404. But rather than continue that, I'm going to break it into smaller pieces.
Where we are
Our current testing regime is comprehensive, but a bit all over the place.
There's a mix of things like
MOI.Test.unittest
that wrap a whole lot of tests, and others likeMOI.Test.default_status_test
that you just need to add. Even the documentation for how to test a solver is complicated (#224)! https://jump.dev/MathOptInterface.jl/dev/submodules/Test/overview/#How-to-test-a-solverThe current design is also bad because it's hard to add new tests.
As evidenced by the documentation: https://jump.dev/MathOptInterface.jl/dev/submodules/Test/overview/#How-to-add-a-test, you need to write a test, then write a test for the test, and then make sure that everything works. It's hard to run a small contingent of tests, and it's hard to decide where to put a new test, and where to put the test of the test.
This also evidenced by the large number of open test issues that aren't getting addressed. These range from #470 (August 2018!) to #1201 (November 2020). If they were easier to add, it would happen quicker!
Naming and visibility of each test is also a problem: #1029. If
linear10btest
fails, what does that mean?New design
The basic design is
runtests
, a single entry point to all tests in MOI.Instead of breaking down tests by files or dictionaries, tests are normal Julia functions with descriptive names that can be excluded or included by the user.
Here's the code to test the
MockOptimizer
:Much better.
There is also a need for certain tests to modify the model prior to running the test (changing solver parameters/tolerances, for example). That can be achieved by overloading
setup_test(::typeof(f), ::MOI.ModelLike, ::MOI.Test.Config)
for the particular functionf
.TODO
Rename MOI.Test to MOI.DeprecatedTest [breaking] Deprecate the MOI.Test submodule #1407
Add core functionality of new MOI.Test, plus documentation (but now actual tests) Add the skeleton of the new MOI.Test submodule #1408 [Test] various fixes to MOI.Test #1428 [Test] change MOI.OPTIMAL to config.optimal_status #1434 [Test] remove supports_optimize in favor of standard exclude #1437
Migrate existing tests, cleaning an clarifying naming conventions file-by-file
Migrate testing of MOI from DeprecatedTest to the new MOI.Test
The text was updated successfully, but these errors were encountered: