Fix pantheon.cli.PantheonCommandTest test on Windows (#380)

Anton Nashatyrev 6 years ago committed by Chris Mckay
parent 7459b263b2
commit e0d4f21e73
  1. 1
      gradle/versions.gradle
  2. 1
      pantheon/build.gradle
  3. 8
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java

@ -73,5 +73,6 @@ dependencyManagement {
dependency 'org.web3j:crypto:4.0.1' dependency 'org.web3j:crypto:4.0.1'
dependency 'org.xerial.snappy:snappy-java:1.1.7.2' dependency 'org.xerial.snappy:snappy-java:1.1.7.2'
dependency 'org.apache.commons:commons-text:1.6'
} }
} }

@ -58,6 +58,7 @@ dependencies {
testImplementation 'org.assertj:assertj-core' testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility' testImplementation 'org.awaitility:awaitility'
testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-core'
testImplementation 'org.apache.commons:commons-text'
} }
task writeInfoFile(type: ProjectPropertiesFile) { task writeInfoFile(type: ProjectPropertiesFile) {

@ -54,6 +54,7 @@ import java.util.Optional;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import org.apache.commons.text.StringEscapeUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
@ -251,7 +252,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final URL configFile = Resources.getResource("complete_config.toml"); final URL configFile = Resources.getResource("complete_config.toml");
final Path genesisFile = createFakeGenesisFile(); final Path genesisFile = createFakeGenesisFile();
final String updatedConfig = final String updatedConfig =
Resources.toString(configFile, UTF_8).replaceAll("~/genesis.json", genesisFile.toString()); Resources.toString(configFile, UTF_8)
.replace("~/genesis.json", escapeTomlString(genesisFile.toString()));
final Path toml = Files.createTempFile("toml", ""); final Path toml = Files.createTempFile("toml", "");
Files.write(toml, updatedConfig.getBytes(UTF_8)); Files.write(toml, updatedConfig.getBytes(UTF_8));
@ -1004,4 +1006,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
private boolean isFullInstantiation() { private boolean isFullInstantiation() {
return !Boolean.getBoolean("pantheon.docker"); return !Boolean.getBoolean("pantheon.docker");
} }
private static String escapeTomlString(final String s) {
return StringEscapeUtils.escapeJava(s);
}
} }

Loading…
Cancel
Save