From f8201c6aa94f6925df63266beb008f9678f0adad Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 10 Oct 2013 18:06:52 +0400 Subject: [PATCH] Refactor TopLevelMembersInvocationTest Compile library dependencies in the test instead of storing them as jars in the repository. Reuse MockLibraryUtil, move it from idea tests to compiler-tests --- .../topLevelMemberInvocation/twoModules/a.jar | Bin 1420 -> 0 bytes .../{a.kt.txt => library/source.kt} | 0 .../org/jetbrains/jet}/MockLibraryUtil.java | 19 ++++++++++++++++-- ...AbstractTopLevelMembersInvocationTest.java | 18 ++++++++++------- .../generators/tests/CompileBinaryTestData.kt | 6 ------ .../JdkAndMockLibraryProjectDescriptor.java | 1 + 6 files changed, 29 insertions(+), 15 deletions(-) delete mode 100644 compiler/testData/codegen/topLevelMemberInvocation/twoModules/a.jar rename compiler/testData/codegen/topLevelMemberInvocation/twoModules/{a.kt.txt => library/source.kt} (100%) rename {idea/tests/org/jetbrains/jet/plugin => compiler/tests/org/jetbrains/jet}/MockLibraryUtil.java (82%) diff --git a/compiler/testData/codegen/topLevelMemberInvocation/twoModules/a.jar b/compiler/testData/codegen/topLevelMemberInvocation/twoModules/a.jar deleted file mode 100644 index 8307a0930ff1cc4e950d1abcd1b469bba557ad82..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1420 zcmWIWW@Zs#-~hr^9Zt>+NPv@pg~8V~#8KDN&rSc|DFy~+h5&DN4v-2asImZ@nni#r z;F^6M{XE@VgG2Ou-9G!CIql=Et9OytTUYDcne&^246YbIcv__A<*VcAd$DvC3+IfN zl1FAsX=PZ5i9A`NRq;&qb>^p{k421N+b@V6%eMiV4ZW& z3`k7QPE1eLP1H>^FiSBsHnh}B&PgmTw(axxKI|ZH^uF2Jm+`Y#T@^dHnaecHQNUHB z)oEi!;K|y_dWpA7wyQ|nPo4hiY_t3UepSDuLcRQFwrO>r|9<|-`hZEc&8(a~SWc%x zqiWCb^Xt?8p8mI$_t=9oKefx1*ExN^IKTVAjSUiAe{vEf_|%IN?^Ne1tu*_+ct*ST z!ZWzmOsUsv&LvrE_yXMlGM;9lCt_kPKnX_~`PnpIUlkFPv*8`pRHZjSx zeadxU$$Tdv<-Att@YIhLQ@E^*t{6{x=A!j+f?loQ{sMcY<-gWkwh&OB$$NKsh~!R@ zc|IyjnU`*P*e2(FLCIyJT*8YKmrJp;xH1kniHnAuys5mraevb5m|ZvAiiItgM2g7fu^JIKY_Ia4_-9q%@I@9*i@sPF394 zmaU%ax#ecXr{h1E_f!_&*eCtR>WAF7o6rANe7pPn*YWS#47WKr*JT`4Pcjfx z&TQu3PW~9UWto!n)?I%$%4kTlEmYg4)|H?YxuPRsP5u{--ulI}lY(t-NV{2I+}9gj z8nGePqJZ<8$EwMZ|Nf=D*wAOSXI0T`0h!*VS*1m$zMJnG^{=Y^mFa)3%j7)I-o=aW z%Wi8?>~ck#EV!VA7PmK2x$bKG-N^XF&(GV{XQce3p6RPFu!?$8{zdDo{j zi@$rc`G|(~@zvh!Z5OMn>qCQ|&6XB4EQ)Yh-o*3C*0JWO;p4J1I}YnK&t5KUqjCGytJrxy3RaVcyH2FZ%?}^Ek75VOg{cJHU8W=*ZNh) z?@sTT!~5j&7Nv)gGgp2I`gTd_>Q#%=MXFQ& z?_OQL6mj?PsVn>Eepz1p?{xiKp6_{Ee04H;O41yS{|l50#58c}{9^${vm^V((3QX_ zmImgu0B=Sn5eC#U1Xe(R$`DilFBCu}3c6P0+zl#05Wp75glk1APe3McG2ku*5GL#f zGC^ems$-GUE2vaJfZIT3qCUGI68rY F2>=)c<6Qs% diff --git a/compiler/testData/codegen/topLevelMemberInvocation/twoModules/a.kt.txt b/compiler/testData/codegen/topLevelMemberInvocation/twoModules/library/source.kt similarity index 100% rename from compiler/testData/codegen/topLevelMemberInvocation/twoModules/a.kt.txt rename to compiler/testData/codegen/topLevelMemberInvocation/twoModules/library/source.kt diff --git a/idea/tests/org/jetbrains/jet/plugin/MockLibraryUtil.java b/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java similarity index 82% rename from idea/tests/org/jetbrains/jet/plugin/MockLibraryUtil.java rename to compiler/tests/org/jetbrains/jet/MockLibraryUtil.java index 66df0c80511..242da1d7140 100644 --- a/idea/tests/org/jetbrains/jet/plugin/MockLibraryUtil.java +++ b/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java @@ -1,8 +1,23 @@ -package org.jetbrains.jet.plugin; +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet; import com.intellij.util.io.ZipUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.cli.common.ExitCode; import org.jetbrains.jet.cli.jvm.K2JVMCompiler; import org.jetbrains.jet.utils.ExceptionUtils; diff --git a/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java b/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java index e557d279423..5f7e6d62e4e 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java @@ -21,6 +21,7 @@ import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.ConfigurationKind; import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.MockLibraryUtil; import org.jetbrains.jet.TestJdkKind; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; @@ -31,24 +32,27 @@ import java.util.Collections; import java.util.List; public abstract class AbstractTopLevelMembersInvocationTest extends AbstractBytecodeTextTest { - + @Override public void doTest(@NotNull String filename) throws Exception { + final File root = new File(filename); final List sourceFiles = new ArrayList(2); - final List classPath = new ArrayList(1); - FileUtil.processFilesRecursively(new File(filename), new Processor() { + FileUtil.processFilesRecursively(root, new Processor() { @Override public boolean process(File file) { if (file.getName().endsWith(".kt")) { sourceFiles.add(file.getPath().substring("compiler/testData/codegen/".length())); + return true; } - else if (file.getName().endsWith(".jar")) { - classPath.add(file); - } - return true; + return FileUtil.filesEqual(file, root); } }); + File library = new File(root, "library"); + List classPath = library.exists() ? + Collections.singletonList(MockLibraryUtil.compileLibraryToJar(library.getPath())) : + Collections.emptyList(); + assert !sourceFiles.isEmpty() : getTestName(true) + " should contains at least one .kt file"; Collections.sort(sourceFiles); diff --git a/generators/src/org/jetbrains/jet/generators/tests/CompileBinaryTestData.kt b/generators/src/org/jetbrains/jet/generators/tests/CompileBinaryTestData.kt index d2afcb57bfb..01b3a5c59f1 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/CompileBinaryTestData.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/CompileBinaryTestData.kt @@ -45,12 +45,6 @@ Retention(RetentionPolicy.RUNTIME) private annotation class GenScript(val dir: String, val source: String, val binary: String) private object BinaryTestData { - GenScript("compiler/testData/codegen/topLevelMemberInvocation/twoModules", "a.kt", "a.jar") - fun genTwoModules() { - jar("a.jar", "a") - rm("a") - } - GenScript("compiler/testData/compileKotlinAgainstBinariesCustom/brokenJarWithNoClassForObjectProperty", "source.kt", "broken.jar") fun genBrokenJarWithNoClassForObjectProperty() { rm("test/Lol.class") diff --git a/idea/tests/org/jetbrains/jet/plugin/JdkAndMockLibraryProjectDescriptor.java b/idea/tests/org/jetbrains/jet/plugin/JdkAndMockLibraryProjectDescriptor.java index 49282ca6d2d..043118f7476 100644 --- a/idea/tests/org/jetbrains/jet/plugin/JdkAndMockLibraryProjectDescriptor.java +++ b/idea/tests/org/jetbrains/jet/plugin/JdkAndMockLibraryProjectDescriptor.java @@ -6,6 +6,7 @@ import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.util.io.FileUtilRt; +import org.jetbrains.jet.MockLibraryUtil; import java.io.File;