Make test independent of the particular stdlib code
In the previous version test would fail every time stdlib changes
This commit is contained in:
@@ -71,7 +71,7 @@ public class NamespaceComparator {
|
|||||||
@NotNull Predicate<NamespaceDescriptor> includeIntoOutput,
|
@NotNull Predicate<NamespaceDescriptor> includeIntoOutput,
|
||||||
@NotNull File txtFile
|
@NotNull File txtFile
|
||||||
) {
|
) {
|
||||||
String serialized = new NamespaceComparator(includeObject, includeIntoOutput).doCompareNamespaces(nsa, nsb);
|
String serialized = assertNamespacesEqual(nsa, nsb, includeObject, includeIntoOutput);
|
||||||
try {
|
try {
|
||||||
if (!txtFile.exists()) {
|
if (!txtFile.exists()) {
|
||||||
FileUtil.writeToFile(txtFile, serialized);
|
FileUtil.writeToFile(txtFile, serialized);
|
||||||
@@ -87,6 +87,13 @@ public class NamespaceComparator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String assertNamespacesEqual(NamespaceDescriptor nsa,
|
||||||
|
NamespaceDescriptor nsb,
|
||||||
|
boolean includeObject,
|
||||||
|
Predicate<NamespaceDescriptor> includeIntoOutput) {
|
||||||
|
return new NamespaceComparator(includeObject, includeIntoOutput).doCompareNamespaces(nsa, nsb);
|
||||||
|
}
|
||||||
|
|
||||||
private static <T extends Comparable<T>> List<T> sorted(Collection<T> items) {
|
private static <T extends Comparable<T>> List<T> sorted(Collection<T> items) {
|
||||||
List<T> r = new ArrayList<T>(items);
|
List<T> r = new ArrayList<T>(items);
|
||||||
Collections.sort(r);
|
Collections.sort(r);
|
||||||
|
|||||||
+5
-6
@@ -53,16 +53,15 @@ public class LazyResolveStdlibLoadingTest extends AbstractLazyResolveTest {
|
|||||||
Function<Pair<ModuleDescriptor, ModuleDescriptor>, Pair<NamespaceDescriptor, NamespaceDescriptor>> transform,
|
Function<Pair<ModuleDescriptor, ModuleDescriptor>, Pair<NamespaceDescriptor, NamespaceDescriptor>> transform,
|
||||||
boolean includeMembersOfObject,
|
boolean includeMembersOfObject,
|
||||||
List<JetFile> files,
|
List<JetFile> files,
|
||||||
Predicate<NamespaceDescriptor> filterJetNamespace,
|
Predicate<NamespaceDescriptor> filterJetNamespace
|
||||||
File serializeResultsTo
|
|
||||||
) {
|
) {
|
||||||
ModuleDescriptor module = resolveEagerly(files, new JetCoreEnvironmentWithDisposable(ConfigurationKind.JDK_AND_ANNOTATIONS, false).jetCoreEnvironment);
|
ModuleDescriptor module = resolveEagerly(files, new JetCoreEnvironmentWithDisposable(ConfigurationKind.JDK_AND_ANNOTATIONS, false).jetCoreEnvironment);
|
||||||
ModuleDescriptor lazyModule = resolveLazily(files, stdlibEnvironment.jetCoreEnvironment);
|
ModuleDescriptor lazyModule = resolveLazily(files, stdlibEnvironment.jetCoreEnvironment);
|
||||||
|
|
||||||
Pair<NamespaceDescriptor, NamespaceDescriptor> namespacesToCompare = transform.fun(Pair.create(module, lazyModule));
|
Pair<NamespaceDescriptor, NamespaceDescriptor> namespacesToCompare = transform.fun(Pair.create(module, lazyModule));
|
||||||
|
|
||||||
NamespaceComparator.compareNamespaces(namespacesToCompare.first, namespacesToCompare.second,
|
NamespaceComparator.assertNamespacesEqual(namespacesToCompare.first, namespacesToCompare.second,
|
||||||
includeMembersOfObject, filterJetNamespace, serializeResultsTo);
|
includeMembersOfObject, filterJetNamespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStdLib() throws Exception {
|
public void testStdLib() throws Exception {
|
||||||
@@ -76,14 +75,14 @@ public class LazyResolveStdlibLoadingTest extends AbstractLazyResolveTest {
|
|||||||
true,
|
true,
|
||||||
//convertToJetFiles(collectKtFiles(new File("compiler/testData/lazyResolve/namespaceComparatorWithJavaMerge"))),
|
//convertToJetFiles(collectKtFiles(new File("compiler/testData/lazyResolve/namespaceComparatorWithJavaMerge"))),
|
||||||
convertToJetFiles(collectKtFiles(STD_LIB_SRC)),
|
convertToJetFiles(collectKtFiles(STD_LIB_SRC)),
|
||||||
Predicates.<NamespaceDescriptor>alwaysTrue(),
|
Predicates.<NamespaceDescriptor>alwaysTrue()
|
||||||
//new Predicate<NamespaceDescriptor>() {
|
//new Predicate<NamespaceDescriptor>() {
|
||||||
// @Override
|
// @Override
|
||||||
// public boolean apply(NamespaceDescriptor descriptor) {
|
// public boolean apply(NamespaceDescriptor descriptor) {
|
||||||
// return Name.identifier("jet").equals(descriptor.getName());
|
// return Name.identifier("jet").equals(descriptor.getName());
|
||||||
// }
|
// }
|
||||||
//},
|
//},
|
||||||
new File("compiler/testData/lazyResolve/namespaceComparatorWithJavaMerge/stdlib-log.txt")
|
//new File("compiler/testData/lazyResolve/namespaceComparatorWithJavaMerge/stdlib-log.txt")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user