Skip to content

Commit

Permalink
#628: Fixed update fails on first error (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-vcapgemini authored Sep 20, 2024
1 parent 22a0d13 commit 90d6b8d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/628[#638]: Fixed update fails on first error
* https://github.com/devonfw/IDEasy/issues/553[#554]: Missmatch of IDE_ROOT
* https://github.com/devonfw/IDEasy/issues/556[#556]: ProcessContext should compute PATH on run and not in constructor
* https://github.com/devonfw/IDEasy/issues/557[#557]: Failed to update tomcat: Cannot find a (Map) Key deserializer for type VersionRange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ private void updateConf() {
}
}

Step step = this.context.newStep("Copy configuration templates", templatesFolder);
try {
try (Step step = this.context.newStep("Copy configuration templates", templatesFolder)) {
setupConf(templatesFolder, this.context.getIdeHome());
step.success();
} finally {
step.close();
}
}

Expand Down Expand Up @@ -137,14 +134,13 @@ private void updateSettings() {

private void updateSoftware() {

Step step = this.context.newStep("Install or update software");
try {
try (Step step = this.context.newStep("Install or update software")) {
Set<ToolCommandlet> toolCommandlets = new HashSet<>();

// installed tools in IDE_HOME/software
List<Path> softwares = this.context.getFileAccess().listChildren(this.context.getSoftwarePath(), Files::isDirectory);
for (Path software : softwares) {
String toolName = software.getFileName().toString();
List<Path> softwarePaths = this.context.getFileAccess().listChildren(this.context.getSoftwarePath(), Files::isDirectory);
for (Path softwarePath : softwarePaths) {
String toolName = softwarePath.getFileName().toString();
ToolCommandlet toolCommandlet = this.context.getCommandletManager().getToolCommandletOrNull(toolName);
if (toolCommandlet != null) {
toolCommandlets.add(toolCommandlet);
Expand All @@ -167,11 +163,14 @@ private void updateSoftware() {

// update/install the toolCommandlets
for (ToolCommandlet toolCommandlet : toolCommandlets) {
toolCommandlet.install(false);
try {
toolCommandlet.install(false);
} catch (Exception e) {
step.error(e, "Installation of {} failed!", toolCommandlet.getName());
}

}
step.success();
} finally {
step.close();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,30 @@ private void deleteTemplatesFolder(IdeContext context) throws IOException {
Files.delete(templates.getParent());
Files.delete(templates.getParent().getParent());
}

/**
* Tests if a sub step (installation of software) of update failed, the overall update process will not fail too.
* <p>
* See: <a href="https://github.com/devonfw/IDEasy/issues/628">#628</a> for reference.
*/
@Test
public void testRunUpdateSoftwareDoesNotFailOnFailedSoftwareInstallations() {

// arrange
IdeTestContext context = newContext(PROJECT_UPDATE);
Path javaRepository = context.getToolRepositoryPath().resolve("default").resolve("java");
context.getFileAccess().delete(javaRepository);
Path javaDownload = context.getIdeRoot().resolve("repository").resolve("java");
context.getFileAccess().delete(javaDownload);
UpdateCommandlet uc = context.getCommandletManager().getCommandlet(UpdateCommandlet.class);

// act
uc.run();

// assert
assertThat(context).logAtError().hasMessage("Installation of java failed!");
assertThat(context).logAtError().hasMessage("Installation of mvn failed!");
assertThat(context).logAtSuccess().hasMessage("Successfully updated settings repository.");
assertThat(context).logAtSuccess().hasMessage("Install or update software");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo java $*
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "mvn $*"

0 comments on commit 90d6b8d

Please sign in to comment.