Skip to content

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

Description

@lesquoyb

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;
	}
}
  1. Observe that the unit test somewhat failed and the fact that an error occured is written in the test view:
    image
  2. Now comment the first line and run again
  3. 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:

  • The try/catch block is not working either and it's like this exception bypasses it
  • There is an exception that you can sometimes see when reloading the experiment multiple time and closing, it also appears in the eclipse console:
Adding exception to error collector1 occurence in exception0 at cycle 0: Java error: index out of bounds
in exception0
in agent exception0
in test  {
	list<unknown> l <- [];
	l[0] <- 1;
}

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions