• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 8144002629

04 Mar 2024 04:56PM UTC coverage: 58.928% (+0.7%) from 58.254%
8144002629

push

github

web-flow
#208: improve test infrastructure # 219: fix wrong executable (#238)

* Add first implementation

* Add javadoc

* Add javadoc

* Using target path instead of ressource path to make sure one-to-one copy of set up folders is used

* Add JavaDoc and mac mock program

* Add support for multiple dependencies while testing

* Minor changes

* Modify mock programs for testing

* Refactored example JmcTest

* Add possibility to set execution path by using the context

* Reenable test after related issue 228 has been merged

* Replace ternary with regular if

* Add missing javadoc

* Add missing javadoc

* remove unnecessary semicolon

* Fix spelling typo

* Minor test changes

* Refactoring FileExtractor class for more modularity

* using const

* Add missing extensions

* Remove unnecessary execption declaration and minor rename

* Fix spelling

* Add javadoc

* Forget dot

* minor change

* Revert "minor change"

This reverts commit ec81c3ce6.

* Revert "Merge branch 'main' into feature/208-MockOutToolRepoRefactorTestInfra"

This reverts commit d58847230, reversing
changes made to f38b3105f.

* Revert "Revert "Merge branch 'main' into feature/208-MockOutToolRepoRefactorTestInfra""

This reverts commit 3e49a0b3d.

* Revert "Revert "minor change""

This reverts commit 2f7b94624.

* fix typo

* #208: review and complete rework

* #208: improved system path

* #208: found and fixed bug on windows

* #208: improve OS mocking

* #208: improve test logging

reveal logs/errors so the developer actually sees what is happening instead of leaving them in the dark

* #208: improve OS detection

* #208: fixed

found and fixed bug in MacOS app detection for JMC, fixed copy file to folder bug, moved !extract logic back to FileAccess, f... (continued)

1580 of 2930 branches covered (53.92%)

Branch coverage included in aggregate %.

4047 of 6619 relevant lines covered (61.14%)

2.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java
1
package com.devonfw.tools.ide.tool;
2

3
import com.devonfw.tools.ide.common.Tag;
4
import com.devonfw.tools.ide.context.IdeContext;
5
import com.devonfw.tools.ide.io.FileAccess;
6
import com.devonfw.tools.ide.log.IdeLogLevel;
7
import com.devonfw.tools.ide.process.ProcessContext;
8
import com.devonfw.tools.ide.process.ProcessErrorHandling;
9
import com.devonfw.tools.ide.repo.ToolRepository;
10
import com.devonfw.tools.ide.version.VersionIdentifier;
11

12
import java.nio.file.Files;
13
import java.nio.file.Path;
14
import java.util.Set;
15

16
/**
17
 * {@link ToolCommandlet} that is installed globally.
18
 */
19
public abstract class GlobalToolCommandlet extends ToolCommandlet {
20

21
  /**
22
   * The constructor.
23
   *
24
   * @param context the {@link IdeContext}.
25
   * @param tool the {@link #getName() tool name}.
26
   * @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of}
27
   * method.
28
   */
29
  public GlobalToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {
30

31
    super(context, tool, tags);
×
32
  }
×
33

34
  @Override
35
  protected boolean isExtract() {
36

37
    // for global tools we usually download installers and do not want to extract them (e.g. installer.msi file shall
38
    // not be extracted)
39
    return false;
×
40
  }
41

42
  @Override
43
  protected boolean doInstall(boolean silent) {
44

45
    Path binaryPath = this.context.getPath().findBinary(Path.of(getBinaryName()));
×
46
    // if force mode is enabled, go through with the installation even if the tool is already installed
47
    if (binaryPath != null && Files.exists(binaryPath) && !this.context.isForceMode()) {
×
48
      IdeLogLevel level = silent ? IdeLogLevel.DEBUG : IdeLogLevel.INFO;
×
49
      this.context.level(level).log("{} is already installed at {}", this.tool, binaryPath);
×
50
      return false;
×
51
    }
52
    String edition = getEdition();
×
53
    ToolRepository toolRepository = this.context.getDefaultToolRepository();
×
54
    VersionIdentifier configuredVersion = getConfiguredVersion();
×
55
    VersionIdentifier resolvedVersion = toolRepository.resolveVersion(this.tool, edition, configuredVersion);
×
56
    // download and install the global tool
57
    FileAccess fileAccess = this.context.getFileAccess();
×
58
    Path target = toolRepository.download(this.tool, edition, resolvedVersion);
×
59
    Path executable = target;
×
60
    Path tmpDir = null;
×
61
    boolean extract = isExtract();
×
62
    if (extract) {
×
63
      tmpDir = fileAccess.createTempDir(getName());
×
64
      Path downloadBinaryPath = tmpDir.resolve(target.getFileName());
×
65
      fileAccess.extract(target, downloadBinaryPath);
×
66
      downloadBinaryPath = fileAccess.findFirst(downloadBinaryPath, Files::isExecutable, false);
×
67
    }
68
    ProcessContext pc = this.context.newProcess().errorHandling(ProcessErrorHandling.WARNING).executable(executable);
×
69
    int exitCode = pc.run();
×
70
    if (tmpDir != null) {
×
71
      fileAccess.delete(tmpDir);
×
72
    }
73
    if (exitCode == 0) {
×
74
      this.context.success("Successfully installed {} in version {}", this.tool, resolvedVersion);
×
75
    } else {
76
      this.context.warning("{} in version {} was not successfully installed", this.tool, resolvedVersion);
×
77
      return false;
×
78
    }
79
    postInstall();
×
80
    return true;
×
81
  }
82

83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc