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: 'findbugs'
|
||||
apply plugin: 'pmd'
|
||||
|
||||
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 {
|
||||
compileOptions {
|
||||
|
|
|
@ -39,12 +39,21 @@ public class LoggingTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setupSuite() throws Exception {
|
||||
logFilesDir = FileUtils.createTempDir("logfiles");
|
||||
System.setProperty(Logging.PROP_LOGFILES_DIR, logFilesDir.getAbsolutePath());
|
||||
File workingDir = new File(System.getProperty("user.dir"));
|
||||
File configFile = new File(workingDir, "src/main/assets/logback.xml");
|
||||
System.out.println(configFile.getAbsolutePath());
|
||||
System.setProperty("logback.configurationFile", configFile.getAbsolutePath());
|
||||
// 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");
|
||||
System.setProperty(Logging.PROP_LOGFILES_DIR, logFilesDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (System.getProperty("logback.configurationFile") == null) {
|
||||
File workingDir = new File(System.getProperty("user.dir"));
|
||||
File configFile = new File(workingDir, "src/main/assets/logback.xml");
|
||||
System.out.println(configFile.getAbsolutePath());
|
||||
System.setProperty("logback.configurationFile", configFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
private Logging logging = new Logging() {
|
||||
|
|
Loading…
Reference in New Issue