• 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

32.53
cli/src/main/java/com/devonfw/tools/ide/os/OperatingSystem.java
1
package com.devonfw.tools.ide.os;
2

3
import java.util.Locale;
4

5
/**
6
 * Enum with the supported operating systems.
7
 */
8
public enum OperatingSystem {
3✔
9
  /** Microsoft Windows. */
10
  WINDOWS("windows"),
7✔
11

12
  /** Apple MacOS (not iOS). */
13
  MAC("mac"),
7✔
14

15
  /** Linux (Ubunutu, Debian, SuSe, etc.) */
16
  LINUX("linux");
7✔
17

18
  private final String title;
19

20
  private OperatingSystem(String title) {
4✔
21

22
    this.title = title;
3✔
23
  }
1✔
24

25
  @Override
26
  public String toString() {
27

28
    return this.title;
3✔
29
  }
30

31
  /**
32
   * @param title the {@link #toString() string representation} of the requested {@link OperatingSystem}.
33
   * @return the according {@link OperatingSystem} or {@code null} if none matches.
34
   */
35
  public static OperatingSystem of(String title) {
36

37
    for (OperatingSystem os : values()) {
16!
38
      if (os.title.equals(title)) {
5✔
39
        return os;
2✔
40
      }
41
    }
42
    return null;
×
43
  }
44

45
  public static OperatingSystem ofName(String osName) {
46

47
    String os = osName.toLowerCase(Locale.ROOT);
4✔
48
    if (os.startsWith("windows")) {
4✔
49
      return OperatingSystem.WINDOWS;
2✔
50
    } else if (os.startsWith("mac") || os.contains("darwin")) {
8!
51
      return OperatingSystem.MAC;
2✔
52
    } else if (os.contains("linux")) {
4!
53
      return OperatingSystem.LINUX;
2✔
54
    } else if (os.contains("bsd")) {
×
55
      return OperatingSystem.LINUX;
×
56
    } else if (os.contains("ix")) {
×
57
      return OperatingSystem.LINUX;
×
58
    } else {
59
      System.err.println("ERROR: Unknown operating system '" + osName + "'");
×
60
      // be tolerant: most of our users are working on windows
61
      // in case of an odd JVM or virtualization issue let us better continue than failing
62
      return OperatingSystem.WINDOWS;
×
63
    }
64
  }
65

66
  /**
67
   * @param suffix the file extension.
68
   * @return {@code true} if the given {@code suffix} is an executable file extension of this {@link OperatingSystem},
69
   * {@code false} otherwise.
70
   */
71
  public boolean isExecutable(String suffix) {
72

73
    if (suffix == null) {
×
74
      return false;
×
75
    }
76
    if (suffix.startsWith(".")) {
×
77
      suffix = suffix.substring(1);
×
78
    }
79
    if (this == WINDOWS) {
×
80
      if (suffix.equals("exe")) {
×
81
        return true;
×
82
      } else if (suffix.equals("msi")) {
×
83
        return true;
×
84
      } else if (suffix.equals("cmd")) {
×
85
        return true;
×
86
      } else if (suffix.equals("bat")) {
×
87
        return true;
×
88
      } else if (suffix.equals("ps1")) {
×
89
        return true;
×
90
      }
91
    } else {
92
      if (suffix.equals("sh")) {
×
93
        return true;
×
94
      } else if ((this == MAC) && suffix.equals("pkg")) {
×
95
        return true;
×
96
      }
97
    }
98
    return false;
×
99
  }
100

101
}
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