Skip to content

Commit 5bdd8cf

Browse files
committed
adding branch coverage
1 parent 990c0ce commit 5bdd8cf

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

components/environment/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ tasks.shadowJar {
5858
extra.set("minimumInstructionCoverage", 0.7)
5959
val excludedClassesCoverage by extra {
6060
listOf(
61+
"datadog.environment.GeneratedSupportedConfigurations", // generated static file
6162
"datadog.environment.JavaVirtualMachine", // depends on OS and JVM vendor
6263
"datadog.environment.JavaVirtualMachine.JvmOptionsHolder", // depends on OS and JVM vendor
6364
"datadog.environment.JvmOptions", // depends on OS and JVM vendor
6465
"datadog.environment.OperatingSystem", // depends on OS
66+
"datadog.environment.SupportedConfigurationSource", // wrapper class
6567
)
6668
}
6769
val excludedClassesBranchCoverage by extra {

components/environment/src/main/java/datadog/environment/ConfigHelper.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ public static Map<String, String> getEnvironmentVariables() {
5656
}
5757
}
5858
}
59-
// if (deprecatedConfigurations.containsKey(key)) {
59+
60+
// TODO: Follow-up - Add deprecation handling
61+
// if (configSource.getDeprecatedConfigurations().containsKey(key)) {
6062
// String warning = "Environment variable " + key + " is deprecated. " +
61-
// (aliasMapping.containsKey(key)
62-
// ? "Please use " + aliasMapping.get(key) + " instead."
63-
// : deprecatedConfigurations.get(key));
64-
// System.err.println(warning); // TODO: REPLACE with log call
63+
// (configSource.getAliasMapping().containsKey(key)
64+
// ? "Please use " + configSource.getAliasMapping().get(key) + " instead."
65+
// : configSource.getDeprecatedConfigurations().get(key));
66+
// System.err.println(warning);
6567
// }
6668
} else {
6769
configs.put(key, value);

components/environment/src/test/java/datadog/environment/ConfigHelperTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public class ConfigHelperTest {
3232
private static final String NON_DD_ALIAS_VAR = "TEST_CONFIG_ALIAS";
3333
private static final String NON_DD_ALIAS_VAL = "test_alias_val_non_dd";
3434

35+
private static final String NEW_ALIAS_TARGET = "DD_NEW_ALIAS_TARGET";
36+
private static final String NEW_ALIAS_KEY_1 = "DD_NEW_ALIAS_KEY_1";
37+
private static final String NEW_ALIAS_KEY_2 = "DD_NEW_ALIAS_KEY_2";
38+
3539
private static ConfigInversionStrictStyle strictness;
3640
private static TestSupportedConfigurationSource testSource;
3741

@@ -43,10 +47,12 @@ static void setUp() {
4347

4448
Map<String, List<String>> testAliases = new HashMap<>();
4549
testAliases.put(TEST_DD_VAR, Arrays.asList(ALIAS_DD_VAR, NON_DD_ALIAS_VAR));
50+
testAliases.put(NEW_ALIAS_TARGET, Arrays.asList(NEW_ALIAS_KEY_1));
4651

4752
Map<String, String> testAliasMapping = new HashMap<>();
4853
testAliasMapping.put(ALIAS_DD_VAR, TEST_DD_VAR);
4954
testAliasMapping.put(NON_DD_ALIAS_VAR, TEST_DD_VAR);
55+
testAliasMapping.put(NEW_ALIAS_KEY_2, NEW_ALIAS_TARGET);
5056

5157
// Create and set test configuration source
5258
testSource =
@@ -186,6 +192,19 @@ void testAliasSkippedWhenBaseAlreadyPresent() {
186192
setEnvVar(NON_DD_ALIAS_VAR, null);
187193
}
188194

195+
@Test
196+
void testInconsistentAliasesAndAliasMapping() {
197+
setEnvVar(NEW_ALIAS_KEY_2, "some_value");
198+
199+
Map<String, String> result = ConfigHelper.getEnvironmentVariables();
200+
201+
assertFalse(result.containsKey(NEW_ALIAS_KEY_2));
202+
assertFalse(result.containsKey(NEW_ALIAS_TARGET));
203+
204+
// Cleanup
205+
setEnvVar(NEW_ALIAS_KEY_2, null);
206+
}
207+
189208
// Copied from utils.TestHelper
190209
@SuppressWarnings("unchecked")
191210
private static void setEnvVar(String envName, String envValue) {

dd-trace-api/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ val minimumBranchCoverage by extra(0.8)
1111
val excludedClassesCoverage by extra(
1212
listOf(
1313
"datadog.trace.api.ConfigDefaults",
14+
"datadog.trace.api.ConfigInversionStrictStyle",
1415
"datadog.trace.api.CorrelationIdentifier",
1516
"datadog.trace.api.DDSpanTypes",
1617
"datadog.trace.api.DDTags",

gradle/jacoco.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ if (!project.ext.hasProperty('excludedClassesBranchCoverage')) {
3737
}
3838

3939
if (!project.ext.hasProperty('excludedClassesInstructionCoverage')) {
40-
project.ext.excludedClassesInstructionCoverage = [
41-
"datadog.environment.GeneratedSupportedConfigurations",
42-
"datadog.environment.SupportedConfigurationSource"] // Generated static file
40+
project.ext.excludedClassesInstructionCoverage = []
4341
}
4442

4543
// defaults can be overridden per project:

0 commit comments

Comments
 (0)