gama-platform / gama

Main repository for developing the 2024+ versions of GAMA
https://gama-platform.org
GNU General Public License v3.0
11 stars 4 forks source link

Some runtime exception in a unit test makes it hang forever #182

Closed lesquoyb closed 2 weeks ago

lesquoyb commented 1 month ago

Describe the bug Usually when a runtime error occurs in a unit test, this test is marked as failed and the execution stops. But I found one case where the exception is just not displayed and the experiment seem to be hanging there forever.

To Reproduce Steps to reproduce the behavior:

  1. Run this model:
    experiment exception  type:test {
    test {
        write 1/0;
        let l <-[];
        l[0] <- 1;
    }
    }
  2. Observe that the unit test somewhat failed and the fact that an error occured is written in the test view: image
  3. Now comment the first line and run again
  4. See that the test is always written as "running" and nothing is added in the tests view image

Expected behavior The tests view should mark this unit test as failed because of a runtime error

Additional context Two things to note:

IndexOutOfBoundsException: Index 0 out of bounds for length 0 java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) java.base/java.util.Objects.checkIndex(Objects.java:359) java.base/java.util.ArrayList.set(ArrayList.java:441) gama.core.util.IList.setValueAtIndex(IList.java:220) gama.gaml.statements.PutStatement.apply(PutStatement.java:229) Java error: index out of bounds at gama.core.runtime.exceptions.GamaRuntimeException.create(GamaRuntimeException.java:72) at gama.core.runtime.ExecutionScope.step(ExecutionScope.java:587) at gama.core.kernel.experiment.DefaultExperimentController.step(DefaultExperimentController.java:219) at gama.core.kernel.experiment.DefaultExperimentController.lambda$0(DefaultExperimentController.java:46) at java.base/java.lang.Thread.run(Thread.java:842) Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.base/java.util.Objects.checkIndex(Objects.java:359) at java.base/java.util.ArrayList.set(ArrayList.java:441) at gama.core.util.IList.setValueAtIndex(IList.java:220) at gama.gaml.statements.PutStatement.apply(PutStatement.java:229) at gama.gaml.statements.AbstractContainerStatement.privateExecuteIn(AbstractContainerStatement.java:328) at gama.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47) at gama.gaml.statements.test.TestStatement.privateExecuteIn(TestStatement.java:145) at gama.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47) at gama.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59) at gama.core.runtime.ExecutionScope.execute(ExecutionScope.java:510) at gama.core.runtime.IScope.execute(IScope.java:443) at gama.core.runtime.IScope.execute(IScope.java:414) at gama.gaml.architecture.reflex.ReflexArchitecture.executeReflexes(ReflexArchitecture.java:126) at gama.gaml.architecture.reflex.ReflexArchitecture.executeOn(ReflexArchitecture.java:112) at gama.core.runtime.ExecutionScope.execute(ExecutionScope.java:510) at gama.core.runtime.IScope.execute(IScope.java:443) at gama.core.metamodel.agent.AbstractAgent.doStep(AbstractAgent.java:269) at gama.core.metamodel.agent.MinimalAgent.doStep(MinimalAgent.java:260) at gama.core.metamodel.agent.AbstractAgent.step(AbstractAgent.java:240) at gama.core.kernel.experiment.BatchAgent.launchSimulationsWithSolution(BatchAgent.java:494) at gama.core.kernel.batch.exploration.Exploration.explore(Exploration.java:251) at gama.core.kernel.batch.exploration.AExplorationAlgorithm.run(AExplorationAlgorithm.java:86) at gama.core.kernel.experiment.BatchAgent.step(BatchAgent.java:233) at gama.core.kernel.experiment.TestAgent.step(TestAgent.java:93) at gama.core.runtime.ExecutionScope.step(ExecutionScope.java:581) ... 3 more

lesquoyb commented 1 month ago

Once it's fixed, uncomment the tests in the file of this commit