Code and workflow simplified in NamespaceComparator
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.cli.jvm.compiler;
|
package org.jetbrains.jet.cli.jvm.compiler;
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.codegen.PropertyCodegen;
|
import org.jetbrains.jet.codegen.PropertyCodegen;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -35,13 +35,12 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
class NamespaceComparator {
|
public class NamespaceComparator {
|
||||||
|
|
||||||
private final boolean includeObject;
|
private final boolean includeObject;
|
||||||
|
|
||||||
@@ -53,21 +52,16 @@ class NamespaceComparator {
|
|||||||
@NotNull File txtFile) {
|
@NotNull File txtFile) {
|
||||||
String serialized = new NamespaceComparator(includeObject).doCompareNamespaces(nsa, nsb);
|
String serialized = new NamespaceComparator(includeObject).doCompareNamespaces(nsa, nsb);
|
||||||
try {
|
try {
|
||||||
while (true) {
|
if (!txtFile.exists()) {
|
||||||
String expected = Files.toString(txtFile, Charset.forName("utf-8")).replace("\r\n", "\n");
|
FileUtil.writeToFile(txtFile, serialized);
|
||||||
|
Assert.fail("Expected data file did not exist. Generating: " + txtFile);
|
||||||
if (expected.contains("kick me")) {
|
|
||||||
// for developer
|
|
||||||
System.err.println("generating " + txtFile);
|
|
||||||
Files.write(serialized, txtFile, Charset.forName("utf-8"));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compare with hardcopy: make sure nothing is lost in output
|
|
||||||
Assert.assertEquals(expected, serialized);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
String expected = FileUtil.loadFile(txtFile);
|
||||||
|
|
||||||
|
// compare with hardcopy: make sure nothing is lost in output
|
||||||
|
Assert.assertEquals(expected, serialized);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user