Thanks to visit codestin.com
Credit goes to github.com

Skip to content

assertPartialFileContent method in SampleFileWriter_Code.ump has a potential infinite loop #2266

@jacquesjack

Description

@jacquesjack

the example that caused this method to break had the argument "actual" be the following

 /*This code was generated using the UMPLE @UMPLE_VERSION@ modeling language!*/
  
  digraph InstanceDiagram {
    node [shape=rectangle]
    edge [arrowhead=none]
  message [label ="Inheritance unresolvable. Ensure that all abstract/interface classes have concrete implementations that can be instantiated"];
  // All associations
}

the expected file was

 /*This code was generated using the UMPLE UMPLE 1.35.0.7523.c616a4dce modeling language!*/
  
  digraph InstanceDiagram {
    node [shape=rectangle]
    edge [arrowhead=none]
  message [label ="Inheritance unresolvable. Ensure that all abstract/interface classes have concrete implementations that can be instantiated"];
  // All associations
}

2 issues here. the multi-line comment is not ignored. (single line comments are ignored) but this should just cause the test to fail since the lines don't match.

The larger issue that causes the infinite loop is if the first line of the two files fails to match it will literally loop forever.
There is a while loop in the assertPartialFileContent that does not terminate IF the first line does not match between the two files.

It will continue to try to match the first line with every line in the comparison file until it reaches the end of the file at which point it repeatedly compare the first line to null forever.

Correct behavior should be that if there is not match between the first line it should fail the test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCrashes or wrong resultstesting

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions