eclipse / reddeer

RedDeer Project
Eclipse Public License 2.0
40 stars 43 forks source link

Error while using the projects import page #2168

Closed damien-urruty-sonarsource closed 2 years ago

damien-urruty-sonarsource commented 2 years ago

Hello!

We have a test randomly failing when trying to import a project. The error is the following:

java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 7
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
    at java.base/java.lang.String.substring(String.java:1874)
    at org.eclipse.reddeer.eclipse.ui.wizards.datatransfer.WizardProjectsImportPage.getProjectLabel(WizardProjectsImportPage.java:193)
    at org.eclipse.reddeer.eclipse.ui.wizards.datatransfer.WizardProjectsImportPage.getProjects(WizardProjectsImportPage.java:116)
    at org.sonarlint.eclipse.its.AbstractSonarLintTest.importExistingProjectIntoWorkspace(AbstractSonarLintTest.java:208)
    at org.sonarlint.eclipse.its.AbstractSonarLintTest.importExistingProjectIntoWorkspace(AbstractSonarLintTest.java:227)
    at org.sonarlint.eclipse.its.SecretsTest.shouldNotTriggerAnalysisForGitIgnoredFiles(SecretsTest.java:75)

The code that we use in our test is the following (can also be found here):

var dialog = new ExternalProjectImportWizardDialog();
dialog.open();
var importPage = new WizardProjectsImportPage(dialog);
importPage.copyProjectsIntoWorkspace(false);
importPage.setRootDirectory(projectFolder.getAbsolutePath());
var projects = importPage.getProjects();
assertThat(projects).hasSize(1);

We do have a video recording in the CI but the project label appears as expected:

Capture d’écran de 2022-04-25 14-56-46

Looking at the reddeer code I see how this error can occur as there is no check on the string. But the '(' should be present as shown in the screenshot. Also as the error points out the size of the label is 7 but I don't know what it is.

Anyone already faced the same problem ? Happy to help further if needed