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:
cpfeiffer 2016-08-30 01:25:43 +02:00
parent b96f2ed301
commit d9283d0f22
2 changed files with 21 additions and 7 deletions

View File

@ -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 {

View File

@ -39,12 +39,21 @@ public class LoggingTest {
@BeforeClass @BeforeClass
public static void setupSuite() throws Exception { public static void setupSuite() throws Exception {
logFilesDir = FileUtils.createTempDir("logfiles"); // properties might be preconfigured in build.gradle because of test ordering problems
System.setProperty(Logging.PROP_LOGFILES_DIR, logFilesDir.getAbsolutePath()); String logDir = System.getProperty(Logging.PROP_LOGFILES_DIR);
File workingDir = new File(System.getProperty("user.dir")); if (logDir != null) {
File configFile = new File(workingDir, "src/main/assets/logback.xml"); logFilesDir = new File(logDir);
System.out.println(configFile.getAbsolutePath()); } else {
System.setProperty("logback.configurationFile", configFile.getAbsolutePath()); 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() { private Logging logging = new Logging() {