-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. support for configurign behaviour via system props, env or config file 3. tests executed in IDE by default are skipped from logs removal
- Loading branch information
Showing
20 changed files
with
798 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,50 @@ | |
|
||
<groupId>com.github.zeldigas</groupId> | ||
<artifactId>reasonable-test-logs</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<version>0.1.0</version> | ||
|
||
<properties> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<scm> | ||
<connection>scm:git:[email protected]:zeldigas/reasonable-test-logs.git</connection> | ||
<developerConnection>scm:git:[email protected]:zeldigas/reasonable-test-logs.git</developerConnection> | ||
<url>https://github.com/zeldigas/Reasonable-Test-Logs</url> | ||
</scm> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT License</name> | ||
<url>http://www.opensource.org/licenses/mit-license.php</url> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Dmitry Pavlov</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
<distributionManagement> | ||
<snapshotRepository> | ||
<id>ossrh</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
</snapshotRepository> | ||
<repository> | ||
<id>ossrh</id> | ||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.platform</groupId> | ||
<artifactId>junit-platform-launcher</artifactId> | ||
<version>1.6.2</version> | ||
<version>1.5.2</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
|
@@ -26,6 +58,113 @@ | |
<version>1.2.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>3.1.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.5.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>release</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<notimestamp>true</notimestamp> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.github.zlika</groupId> | ||
<artifactId>reproducible-build-maven-plugin</artifactId> | ||
<version>0.12</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>strip-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<version>1.6</version> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<gpgArguments> | ||
<arg>--pinentry-mode</arg> | ||
<arg>loopback</arg> | ||
</gpgArguments> | ||
<passphraseServerId>${gpg.keyname}</passphraseServerId> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.sonatype.plugins</groupId> | ||
<artifactId>nexus-staging-maven-plugin</artifactId> | ||
<version>1.6.8</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<serverId>ossrh</serverId> | ||
<nexusUrl>https://oss.sonatype.org/</nexusUrl> | ||
<autoReleaseAfterClose>true</autoReleaseAfterClose> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
|
||
</project> |
96 changes: 96 additions & 0 deletions
96
reasonable-test-logs/src/main/java/com/github/zeldigas/rtlogs/Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.github.zeldigas.rtlogs; | ||
|
||
import java.io.InputStream; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
public class Config { | ||
|
||
public static final String CONFIG_FILE = "/reasonable-test-logs.properties"; | ||
private static final String PROPS_PREFIX = "rtlogs."; | ||
private static final String PROP_CONTROLLER_TYPE = PROPS_PREFIX + "mode"; | ||
private static final String PROP_DEBUG = PROPS_PREFIX + "debug"; | ||
|
||
enum ControllerType { | ||
AUTO, NOP, REASONABLE | ||
} | ||
|
||
private final ControllerType controllerType; | ||
private final boolean debug; | ||
|
||
public Config(ControllerType controllerType, boolean debug) { | ||
this.controllerType = controllerType; | ||
this.debug = debug; | ||
} | ||
|
||
public ControllerType getControllerType() { | ||
return controllerType; | ||
} | ||
|
||
public boolean isDebug() { | ||
return debug; | ||
} | ||
|
||
public static Config load() { | ||
return load(CONFIG_FILE); | ||
} | ||
|
||
static Config load(String file) { | ||
Properties properties = defaultProperties(); | ||
mergeTo(loadConfigFile(file), properties); | ||
mergeTo(System.getProperties(), properties); | ||
mergeTo(propertiesFromEnvVars(), properties); | ||
|
||
return new Config( | ||
ControllerType.valueOf(properties.getProperty(PROP_CONTROLLER_TYPE).toUpperCase()), | ||
toBool(properties.getProperty(PROP_DEBUG)) | ||
); | ||
} | ||
|
||
private static Properties loadConfigFile(String file) { | ||
Properties properties = new Properties(); | ||
InputStream config = Config.class.getResourceAsStream(file); | ||
if (config != null) { | ||
try { | ||
properties.load(config); | ||
} catch (Exception e) { | ||
System.err.println("Failed to load properties from " + file + " file"); | ||
e.printStackTrace(); | ||
} | ||
} | ||
return properties; | ||
} | ||
|
||
private static void mergeTo(Properties source, Properties dest) { | ||
source.forEach((k, v) -> { | ||
if (k.toString().startsWith(PROPS_PREFIX)) { | ||
dest.put(k, v); | ||
} | ||
}); | ||
} | ||
|
||
private static boolean toBool(String value) { | ||
return Boolean.parseBoolean(value); | ||
} | ||
|
||
private static Properties defaultProperties() { | ||
Properties properties = new Properties(); | ||
properties.setProperty(PROP_CONTROLLER_TYPE, "auto"); | ||
properties.setProperty(PROP_DEBUG, "false"); | ||
return properties; | ||
} | ||
|
||
private static Properties propertiesFromEnvVars() { | ||
Properties properties = new Properties(); | ||
Map<String, String> envVars = System.getenv(); | ||
if (envVars.containsKey("RTLOGS_MODE")) { | ||
properties.setProperty(PROP_CONTROLLER_TYPE, envVars.get("RTLOGS_MODE")); | ||
} | ||
if (envVars.containsKey("RTLOGS_DEBUG")) { | ||
properties.setProperty(PROP_DEBUG, envVars.get("RTLOGS_DEBUG")); | ||
} | ||
return properties; | ||
} | ||
|
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
reasonable-test-logs/src/main/java/com/github/zeldigas/rtlogs/ExecutionEnvironment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.zeldigas.rtlogs; | ||
|
||
public class ExecutionEnvironment { | ||
|
||
public static boolean ideMode() { | ||
String val = System.getProperties().getProperty("sun.java.command"); | ||
return isRunningInIntellij(val); | ||
} | ||
|
||
private static boolean isRunningInIntellij(String val) { | ||
return val.startsWith("com.intellij.rt."); | ||
} | ||
|
||
} |
Oops, something went wrong.