Logging improvement

This commit is contained in:
Ilya.Kazakevich
2016-12-09 01:14:10 +03:00
parent 59f4e45d2f
commit a6cf0fbcfb
2 changed files with 10 additions and 6 deletions
+9 -5
View File
@@ -23,6 +23,7 @@ import java.util.Set;
* @author traff
*/
public class PyEnvTaskRunner {
private static final Logger LOG = Logger.getInstance(PyEnvTaskRunner.class);
private final List<String> myRoots;
public PyEnvTaskRunner(List<String> roots) {
@@ -36,9 +37,13 @@ public class PyEnvTaskRunner {
List<String> passedRoots = Lists.newArrayList();
for (String root : myRoots) {
LOG.warn(String.format("Running on root %s", root));
final Set<String> requredTags = Sets.union(testTask.getTags(), Sets.newHashSet(tagsRequiedByTest));
if (!isSuitableForTask(PyEnvTestCase.loadEnvTags(root), requredTags) || !shouldRun(root, testTask)) {
final boolean suitableForTask = isSuitableForTask(PyEnvTestCase.loadEnvTags(root), requredTags);
final boolean shouldRun = shouldRun(root, testTask);
if (!suitableForTask || !shouldRun) {
LOG.warn(String.format("Skipping %s (compatible with tags: %s, should run:%s)", root, suitableForTask, shouldRun));
continue;
}
@@ -66,19 +71,18 @@ public class PyEnvTaskRunner {
passedRoots.add(root);
}
else {
System.err.println(String.format("Skipping root %s", root));
LOG.warn(String.format("Skipping root %s", root));
}
}
catch (final Throwable e) {
final Logger logger = Logger.getInstance(PyEnvTaskRunner.class);
// Direct output of enteredTheMatrix may break idea or TC since can't distinguish test output from real test result
// Exception is thrown anyway, so we escape message before logging
if (e.getMessage().contains("enteredTheMatrix")) {
// .error( may lead to new exception with out of stacktrace.
logger.warn(PyEnvTestCase.escapeTestMessage(e.getMessage()));
LOG.warn(PyEnvTestCase.escapeTestMessage(e.getMessage()));
}
else {
logger.error(e);
LOG.error(e);
}
throw new RuntimeException(
PyEnvTestCase.joinStrings(passedRoots, "Tests passed environments: ") + "Test failed on " + getEnvType() + " environment " + root,
+1 -1
View File
@@ -333,7 +333,7 @@ public final class PyToxTest extends PyEnvTestCase {
}
Assert
.assertThat("No all interpreters from tox.ini used", expectedInterpreters, Matchers.everyItem(Matchers.isIn(checkedInterpreters)));
.assertThat("No all interpreters from tox.ini used", checkedInterpreters, Matchers.everyItem(Matchers.isIn(expectedInterpreters)));
assert !skippedInterpreters.equals(expectedInterpreters) : "All interpreters skipped (they do not exist on platform), " +
"we test nothing";
}