Skip to content

Commit 4574fc7

Browse files
Undinyopox
authored andcommitted
T: allow using WithExperimentalFeatures in RsWithToolchainTestBase tests
1 parent 82886bd commit 4574fc7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/test/kotlin/org/rust/cargo/RsWithToolchainTestBase.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.rust.cargo
77

8+
import com.intellij.findAnnotationInstance
89
import com.intellij.openapi.Disposable
910
import com.intellij.openapi.util.Disposer
1011
import com.intellij.openapi.util.RecursionManager
@@ -84,6 +85,7 @@ abstract class RsWithToolchainTestBase : CodeInsightFixtureTestCase<ModuleFixtur
8485
if (disableMissedCacheAssertions) {
8586
RecursionManager.disableMissedCacheAssertions(testRootDisposable)
8687
}
88+
setupExperimentalFeatures()
8789
setupResolveEngine(project, testRootDisposable)
8890
findAnnotationInstance<ExpandMacros>()?.let { ann ->
8991
Disposer.register(
@@ -98,6 +100,12 @@ abstract class RsWithToolchainTestBase : CodeInsightFixtureTestCase<ModuleFixtur
98100
setExperimentalFeatureEnabled(RsExperiments.FETCH_ACTUAL_STDLIB_METADATA, fetchActualStdlibMetadata, testRootDisposable)
99101
}
100102

103+
private fun setupExperimentalFeatures() {
104+
for (feature in findAnnotationInstance<WithExperimentalFeatures>()?.features.orEmpty()) {
105+
setExperimentalFeatureEnabled(feature, true, testRootDisposable)
106+
}
107+
}
108+
101109
override fun tearDown() {
102110
Disposer.dispose(earlyTestRootDisposable)
103111
rustupFixture.tearDown()
@@ -114,10 +122,6 @@ abstract class RsWithToolchainTestBase : CodeInsightFixtureTestCase<ModuleFixtur
114122
protected fun buildProject(builder: FileTreeBuilder.() -> Unit): TestProject =
115123
fileTree { builder() }.create()
116124

117-
/** Tries to find the specified annotation on the current test method and then on the current class */
118-
private inline fun <reified T : Annotation> findAnnotationInstance(): T? =
119-
javaClass.getMethod(name).getAnnotation(T::class.java) ?: javaClass.getAnnotation(T::class.java)
120-
121125
/**
122126
* Tries to launches [action]. If it returns `false`, invokes [UIUtil.dispatchAllInvocationEvents] and tries again
123127
*

0 commit comments

Comments
 (0)