mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix GroovyCompilerTest, add a test for failing single file recompilation
This commit is contained in:
+45
-4
@@ -561,7 +561,7 @@ class Indirect {
|
||||
|
||||
touch(used.virtualFile)
|
||||
touch(main)
|
||||
assertEmpty make()
|
||||
assert make().collect { it.message } == chunkRebuildMessage('Groovy stub generator')
|
||||
|
||||
assertEmpty compileModule(myModule)
|
||||
assertEmpty compileModule(myModule)
|
||||
@@ -577,6 +577,8 @@ class Indirect {
|
||||
assert findClassFile('Used2') == null
|
||||
}
|
||||
|
||||
protected abstract List<String> chunkRebuildMessage(String builder)
|
||||
|
||||
void testClassLoadingDuringBytecodeGeneration() {
|
||||
def used = myFixture.addFileToProject('Used.groovy', 'class Used { }')
|
||||
def java = myFixture.addFileToProject('Java.java', '''
|
||||
@@ -595,7 +597,7 @@ class Main {
|
||||
|
||||
touch(used.virtualFile)
|
||||
touch(main)
|
||||
assertEmpty make()
|
||||
assert make().collect { it.message } == chunkRebuildMessage("Groovy compiler")
|
||||
}
|
||||
|
||||
void testMakeInDependentModuleAfterChunkRebuild() {
|
||||
@@ -613,7 +615,7 @@ class Main {
|
||||
touch(main)
|
||||
setFileText(dep, 'class Dep { String prop = new Used().getProp(); }')
|
||||
|
||||
assertEmpty make()
|
||||
assert make().collect { it.message } == chunkRebuildMessage('Groovy stub generator')
|
||||
}
|
||||
|
||||
void "test extend package-private class from another module"() {
|
||||
@@ -815,7 +817,7 @@ string
|
||||
touch bar3.virtualFile
|
||||
touch using.virtualFile
|
||||
|
||||
assertEmpty make()
|
||||
assert make().collect { it.message } == chunkRebuildMessage('Groovy compiler')
|
||||
}
|
||||
|
||||
void "test rename class to java and touch its usage"() {
|
||||
@@ -941,6 +943,36 @@ class AppTest {
|
||||
assert !make().find { it.category == CompilerMessageCategory.ERROR }
|
||||
}
|
||||
|
||||
void "test recompile one file that triggers chunk rebuild inside"() {
|
||||
myFixture.addFileToProject('BuildContext.groovy', '''
|
||||
@groovy.transform.CompileStatic
|
||||
class BuildContext {
|
||||
static BuildContext createContext(PropTools tools) { return BuildContextImpl.create(tools) }
|
||||
}
|
||||
|
||||
''')
|
||||
myFixture.addFileToProject('PropTools.groovy', 'class PropTools { SomeTool someTool }')
|
||||
myFixture.addFileToProject('SomeTool.groovy', 'interface SomeTool { void call(BuildContext ctx) }')
|
||||
def subText = '''
|
||||
@groovy.transform.CompileStatic
|
||||
class BuildContextImpl extends BuildContext {
|
||||
static BuildContextImpl create(PropTools tools) { return new BuildContextImpl() }
|
||||
void foo(SomeTool tool) { tool.call(this) }
|
||||
}
|
||||
'''
|
||||
def sub = myFixture.addFileToProject('BuildContextImpl.groovy', subText)
|
||||
assertEmpty(make())
|
||||
|
||||
setFileText(sub, subText + ' ')
|
||||
assert make().collect { it.message } == chunkRebuildMessage('Groovy compiler')
|
||||
def fileMessages = compileFiles(sub.virtualFile)
|
||||
if (this instanceof GroovycTest) {
|
||||
assert fileMessages.collect { it.message == 'Consider building whole project or rebuilding the module' }
|
||||
} else {
|
||||
assert fileMessages.empty
|
||||
}
|
||||
}
|
||||
|
||||
void "test report real compilation errors"() {
|
||||
addModule('another', true)
|
||||
|
||||
@@ -984,6 +1016,10 @@ class Bar {}'''
|
||||
assert msg.message.contains('org.apache.commons.logging.Log')
|
||||
}
|
||||
|
||||
protected List<String> chunkRebuildMessage(String builder) {
|
||||
return ['Builder "' + builder + '" requested rebuild of module chunk "mainModule"']
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class EclipseTest extends GroovyCompilerTest {
|
||||
@@ -1008,5 +1044,10 @@ class Bar {}'''
|
||||
|
||||
super.runTest()
|
||||
}
|
||||
|
||||
protected List<String> chunkRebuildMessage(String builder) {
|
||||
return []
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
@@ -12,6 +12,7 @@ import com.intellij.execution.executors.DefaultRunExecutor
|
||||
import com.intellij.execution.impl.DefaultJavaProgramRunner
|
||||
import com.intellij.execution.process.*
|
||||
import com.intellij.execution.runners.ProgramRunner
|
||||
import com.intellij.module.ModuleGroupTestsKt
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.Result
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
@@ -66,6 +67,7 @@ abstract class GroovyCompilerTestCase extends JavaCodeInsightFixtureTestCase imp
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp()
|
||||
ModuleGroupTestsKt.renameModule(myModule, "mainModule")
|
||||
myCompilerTester = new CompilerTester(myModule)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user