Sigh. Fix LoggingTest on Travis
When running all tests from gradle, they are executed in a single VM, and from a quick look it is not configurable to start LoggingTest in a separate VM (in order to enforce fresh logback configuration). Thus, previously started tests interfere with the custom logback configuration of LoggingTest. => Set the logback configuration in advance in build.gradle
This commit is contained in:
parent
b96f2ed301
commit
d9283d0f22
|
@ -1,10 +1,15 @@
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'findbugs'
|
apply plugin: 'findbugs'
|
||||||
apply plugin: 'pmd'
|
apply plugin: 'pmd'
|
||||||
|
|
||||||
def ABORT_ON_CHECK_FAILURE=false
|
def ABORT_ON_CHECK_FAILURE=false
|
||||||
|
|
||||||
tasks.withType(Test) { systemProperty 'MiFirmwareDir', System.getProperty('MiFirmwareDir', null) }
|
tasks.withType(Test) {
|
||||||
|
systemProperty 'MiFirmwareDir', System.getProperty('MiFirmwareDir', null)
|
||||||
|
systemProperty 'logback.configurationFile', System.getProperty('user.dir', null) + '/app/src/main/assets/logback.xml'
|
||||||
|
systemProperty 'GB_LOGFILES_DIR', java.nio.file.Files.createTempDirectory('gblog').toString();
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|
|
@ -39,13 +39,22 @@ public class LoggingTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupSuite() throws Exception {
|
public static void setupSuite() throws Exception {
|
||||||
|
// properties might be preconfigured in build.gradle because of test ordering problems
|
||||||
|
String logDir = System.getProperty(Logging.PROP_LOGFILES_DIR);
|
||||||
|
if (logDir != null) {
|
||||||
|
logFilesDir = new File(logDir);
|
||||||
|
} else {
|
||||||
logFilesDir = FileUtils.createTempDir("logfiles");
|
logFilesDir = FileUtils.createTempDir("logfiles");
|
||||||
System.setProperty(Logging.PROP_LOGFILES_DIR, logFilesDir.getAbsolutePath());
|
System.setProperty(Logging.PROP_LOGFILES_DIR, logFilesDir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System.getProperty("logback.configurationFile") == null) {
|
||||||
File workingDir = new File(System.getProperty("user.dir"));
|
File workingDir = new File(System.getProperty("user.dir"));
|
||||||
File configFile = new File(workingDir, "src/main/assets/logback.xml");
|
File configFile = new File(workingDir, "src/main/assets/logback.xml");
|
||||||
System.out.println(configFile.getAbsolutePath());
|
System.out.println(configFile.getAbsolutePath());
|
||||||
System.setProperty("logback.configurationFile", configFile.getAbsolutePath());
|
System.setProperty("logback.configurationFile", configFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Logging logging = new Logging() {
|
private Logging logging = new Logging() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue