|
1 |
| -/* |
2 |
| - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. |
3 |
| - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. |
4 |
| - */ |
5 |
| - |
6 |
| -package org.jetbrains.kotlin.arguments |
7 |
| - |
8 |
| -import org.jetbrains.kotlin.cli.common.arguments.* |
9 |
| -import org.junit.Assert.assertEquals |
10 |
| -import org.junit.Test |
11 |
| -import kotlin.reflect.KProperty |
12 |
| - |
13 |
| -class CompilerArgumentsContentProspectorTest { |
14 |
| - |
15 |
| - @Test |
16 |
| - fun testJVMArgumentsContent() { |
17 |
| - if (true) { |
18 |
| - return // temporarily ignore the test KT-50594 |
19 |
| - } |
20 |
| - val flagProperties = CompilerArgumentsContentProspector.getFlagCompilerArgumentProperties(K2JVMCompilerArguments::class) |
21 |
| - val stringProperties = CompilerArgumentsContentProspector.getStringCompilerArgumentProperties(K2JVMCompilerArguments::class) |
22 |
| - val arrayProperties = CompilerArgumentsContentProspector.getArrayCompilerArgumentProperties(K2JVMCompilerArguments::class) |
23 |
| - |
24 |
| - assertContentEquals(flagProperties, k2JVMCompilerArgumentsFlagProperties) |
25 |
| - assertContentEquals(stringProperties, k2JVMCompilerArgumentsStringProperties) |
26 |
| - assertContentEquals(arrayProperties, k2JVMCompilerArgumentsArrayArgumentProperties) |
27 |
| - } |
28 |
| - |
29 |
| - @Test |
30 |
| - fun testMetadataArgumentsContent() { |
31 |
| - if (true) { |
32 |
| - return // temporarily ignore the test KT-50594 |
33 |
| - } |
34 |
| - val flagProperties = CompilerArgumentsContentProspector.getFlagCompilerArgumentProperties(K2MetadataCompilerArguments::class) |
35 |
| - val stringProperties = CompilerArgumentsContentProspector.getStringCompilerArgumentProperties(K2MetadataCompilerArguments::class) |
36 |
| - val arrayProperties = CompilerArgumentsContentProspector.getArrayCompilerArgumentProperties(K2MetadataCompilerArguments::class) |
37 |
| - |
38 |
| - assertContentEquals(flagProperties, k2MetadataCompilerArgumentsFlagProperties) |
39 |
| - assertContentEquals(stringProperties, k2MetadataCompilerArgumentsStringProperties) |
40 |
| - assertContentEquals(arrayProperties, k2MetadataCompilerArgumentsArrayProperties) |
41 |
| - } |
42 |
| - |
43 |
| - @Test |
44 |
| - fun testJsArgumentsContent() { |
45 |
| - if (true) { |
46 |
| - return // temporarily ignore the test KT-50594 |
47 |
| - } |
48 |
| - val flagProperties = CompilerArgumentsContentProspector.getFlagCompilerArgumentProperties(K2JSCompilerArguments::class) |
49 |
| - val stringProperties = CompilerArgumentsContentProspector.getStringCompilerArgumentProperties(K2JSCompilerArguments::class) |
50 |
| - val arrayProperties = CompilerArgumentsContentProspector.getArrayCompilerArgumentProperties(K2JSCompilerArguments::class) |
51 |
| - |
52 |
| - assertContentEquals(flagProperties, k2JSCompilerArgumentsFlagProperties) |
53 |
| - assertContentEquals(stringProperties, k2JSCompilerArgumentsStringProperties) |
54 |
| - assertContentEquals(arrayProperties, k2JSCompilerArgumentsArrayProperties) |
55 |
| - } |
56 |
| - |
57 |
| - companion object { |
58 |
| - |
59 |
| - private val commonToolArgumentsFlagProperties = listOf( |
60 |
| - CommonToolArguments::allWarningsAsErrors, |
61 |
| - CommonToolArguments::extraHelp, |
62 |
| - CommonToolArguments::help, |
63 |
| - CommonToolArguments::suppressWarnings, |
64 |
| - CommonToolArguments::verbose, |
65 |
| - CommonToolArguments::version, |
66 |
| - ) |
67 |
| - |
68 |
| - private val commonCompilerArgumentsFlagProperties = commonToolArgumentsFlagProperties + listOf( |
69 |
| - CommonCompilerArguments::allowKotlinPackage, |
70 |
| - CommonCompilerArguments::progressiveMode, |
71 |
| - CommonCompilerArguments::script, |
72 |
| - CommonCompilerArguments::noInline, |
73 |
| - CommonCompilerArguments::skipMetadataVersionCheck, |
74 |
| - CommonCompilerArguments::skipPrereleaseCheck, |
75 |
| - CommonCompilerArguments::reportOutputFiles, |
76 |
| - CommonCompilerArguments::multiPlatform, |
77 |
| - CommonCompilerArguments::noCheckActual, |
78 |
| - CommonCompilerArguments::newInference, |
79 |
| - CommonCompilerArguments::inlineClasses, |
80 |
| - CommonCompilerArguments::reportPerf, |
81 |
| - CommonCompilerArguments::listPhases, |
82 |
| - CommonCompilerArguments::profilePhases, |
83 |
| - CommonCompilerArguments::checkPhaseConditions, |
84 |
| - CommonCompilerArguments::extraWarnings, |
85 |
| - CommonCompilerArguments::useFirExperimentalCheckers, |
86 |
| - CommonCompilerArguments::metadataKlib, |
87 |
| - CommonCompilerArguments::disableDefaultScriptingPlugin, |
88 |
| - CommonCompilerArguments::suppressVersionWarnings |
89 |
| - ) |
90 |
| - |
91 |
| - private val commonCompilerArgumentsStringProperties = listOf( |
92 |
| - CommonCompilerArguments::languageVersion, |
93 |
| - CommonCompilerArguments::apiVersion, |
94 |
| - CommonCompilerArguments::intellijPluginRoot, |
95 |
| - CommonCompilerArguments::dumpPerf, |
96 |
| - CommonCompilerArguments::metadataVersion, |
97 |
| - CommonCompilerArguments::dumpDirectory, |
98 |
| - CommonCompilerArguments::dumpOnlyFqName, |
99 |
| - CommonCompilerArguments::explicitApi, |
100 |
| - CommonCompilerArguments::kotlinHome |
101 |
| - ) |
102 |
| - private val commonCompilerArgumentsArrayProperties = listOf( |
103 |
| - CommonCompilerArguments::pluginOptions, |
104 |
| - CommonCompilerArguments::pluginClasspaths, |
105 |
| - CommonCompilerArguments::optIn, |
106 |
| - CommonCompilerArguments::commonSources, |
107 |
| - CommonCompilerArguments::disablePhases, |
108 |
| - CommonCompilerArguments::verbosePhases, |
109 |
| - CommonCompilerArguments::phasesToDumpBefore, |
110 |
| - CommonCompilerArguments::phasesToDumpAfter, |
111 |
| - CommonCompilerArguments::phasesToDump, |
112 |
| - CommonCompilerArguments::phasesToValidateBefore, |
113 |
| - CommonCompilerArguments::phasesToValidateAfter, |
114 |
| - CommonCompilerArguments::phasesToValidate, |
115 |
| - ) |
116 |
| - |
117 |
| - private val k2JVMCompilerArgumentsFlagProperties = commonCompilerArgumentsFlagProperties + listOf( |
118 |
| - K2JVMCompilerArguments::includeRuntime, |
119 |
| - K2JVMCompilerArguments::noJdk, |
120 |
| - K2JVMCompilerArguments::noStdlib, |
121 |
| - K2JVMCompilerArguments::noReflect, |
122 |
| - K2JVMCompilerArguments::javaParameters, |
123 |
| - K2JVMCompilerArguments::allowUnstableDependencies, |
124 |
| - K2JVMCompilerArguments::doNotClearBindingContext, |
125 |
| - K2JVMCompilerArguments::noCallAssertions, |
126 |
| - K2JVMCompilerArguments::noReceiverAssertions, |
127 |
| - K2JVMCompilerArguments::noParamAssertions, |
128 |
| - K2JVMCompilerArguments::noOptimize, |
129 |
| - K2JVMCompilerArguments::inheritMultifileParts, |
130 |
| - K2JVMCompilerArguments::useTypeTable, |
131 |
| - K2JVMCompilerArguments::useOldClassFilesReading, |
132 |
| - K2JVMCompilerArguments::suppressMissingBuiltinsError, |
133 |
| - K2JVMCompilerArguments::useJavac, |
134 |
| - K2JVMCompilerArguments::compileJava, |
135 |
| - K2JVMCompilerArguments::disableStandardScript, |
136 |
| - K2JVMCompilerArguments::strictMetadataVersionSemantics, |
137 |
| - K2JVMCompilerArguments::suppressDeprecatedJvmTargetWarning, |
138 |
| - K2JVMCompilerArguments::typeEnhancementImprovementsInStrictMode, |
139 |
| - K2JVMCompilerArguments::sanitizeParentheses, |
140 |
| - K2JVMCompilerArguments::allowNoSourceFiles, |
141 |
| - K2JVMCompilerArguments::emitJvmTypeAnnotations, |
142 |
| - K2JVMCompilerArguments::noResetJarTimestamps, |
143 |
| - K2JVMCompilerArguments::noUnifiedNullChecks, |
144 |
| - K2JVMCompilerArguments::useOldInlineClassesManglingScheme, |
145 |
| - K2JVMCompilerArguments::enableJvmPreview, |
146 |
| - K2JVMCompilerArguments::valueClasses, |
147 |
| - ) |
148 |
| - |
149 |
| - private val k2JVMCompilerArgumentsStringProperties = commonCompilerArgumentsStringProperties + listOf( |
150 |
| - K2JVMCompilerArguments::destination, |
151 |
| - K2JVMCompilerArguments::classpath, |
152 |
| - K2JVMCompilerArguments::jdkHome, |
153 |
| - K2JVMCompilerArguments::expression, |
154 |
| - K2JVMCompilerArguments::moduleName, |
155 |
| - K2JVMCompilerArguments::jvmTarget, |
156 |
| - K2JVMCompilerArguments::abiStability, |
157 |
| - K2JVMCompilerArguments::javaModulePath, |
158 |
| - K2JVMCompilerArguments::assertionsMode, |
159 |
| - K2JVMCompilerArguments::buildFile, |
160 |
| - K2JVMCompilerArguments::javaPackagePrefix, |
161 |
| - K2JVMCompilerArguments::supportCompatqualCheckerFrameworkAnnotations, |
162 |
| - K2JVMCompilerArguments::jspecifyAnnotations, |
163 |
| - K2JVMCompilerArguments::jvmDefault, |
164 |
| - K2JVMCompilerArguments::defaultScriptExtension, |
165 |
| - K2JVMCompilerArguments::stringConcat, |
166 |
| - K2JVMCompilerArguments::klibLibraries, |
167 |
| - K2JVMCompilerArguments::profileCompilerCommand, |
168 |
| - K2JVMCompilerArguments::lambdas, |
169 |
| - K2JVMCompilerArguments::samConversions |
170 |
| - ) |
171 |
| - |
172 |
| - private val k2JVMCompilerArgumentsArrayArgumentProperties = commonCompilerArgumentsArrayProperties + listOf( |
173 |
| - K2JVMCompilerArguments::scriptTemplates, |
174 |
| - K2JVMCompilerArguments::additionalJavaModules, |
175 |
| - K2JVMCompilerArguments::scriptResolverEnvironment, |
176 |
| - K2JVMCompilerArguments::javacArguments, |
177 |
| - K2JVMCompilerArguments::javaSourceRoots, |
178 |
| - K2JVMCompilerArguments::jsr305, |
179 |
| - K2JVMCompilerArguments::friendPaths |
180 |
| - ) |
181 |
| - |
182 |
| - private val k2MetadataCompilerArgumentsFlagProperties = commonCompilerArgumentsFlagProperties |
183 |
| - private val k2MetadataCompilerArgumentsStringProperties = commonCompilerArgumentsStringProperties + listOf( |
184 |
| - K2MetadataCompilerArguments::destination, |
185 |
| - K2MetadataCompilerArguments::classpath, |
186 |
| - K2MetadataCompilerArguments::moduleName |
187 |
| - ) |
188 |
| - private val k2MetadataCompilerArgumentsArrayProperties = commonCompilerArgumentsArrayProperties + listOf( |
189 |
| - K2MetadataCompilerArguments::friendPaths, |
190 |
| - K2MetadataCompilerArguments::refinesPaths |
191 |
| - ) |
192 |
| - private val k2JSCompilerArgumentsFlagProperties = commonCompilerArgumentsFlagProperties + listOf( |
193 |
| - K2JSCompilerArguments::sourceMap, |
194 |
| - K2JSCompilerArguments::irProduceKlibDir, |
195 |
| - K2JSCompilerArguments::irProduceKlibFile, |
196 |
| - K2JSCompilerArguments::irProduceJs, |
197 |
| - K2JSCompilerArguments::irDce, |
198 |
| - K2JSCompilerArguments::irDcePrintReachabilityInfo, |
199 |
| - K2JSCompilerArguments::irPropertyLazyInitialization, |
200 |
| - K2JSCompilerArguments::irPerModule, |
201 |
| - K2JSCompilerArguments::generateDts, |
202 |
| - K2JSCompilerArguments::useEsClasses, |
203 |
| - K2JSCompilerArguments::friendModulesDisabled, |
204 |
| - K2JSCompilerArguments::fakeOverrideValidator, |
205 |
| - K2JSCompilerArguments::wasm |
206 |
| - ) |
207 |
| - private val k2JSCompilerArgumentsStringProperties = commonCompilerArgumentsStringProperties + listOf( |
208 |
| - K2JSCompilerArguments::outputDir, |
209 |
| - K2JSCompilerArguments::moduleName, |
210 |
| - K2JSCompilerArguments::libraries, |
211 |
| - K2JSCompilerArguments::sourceMapPrefix, |
212 |
| - K2JSCompilerArguments::sourceMapBaseDirs, |
213 |
| - K2JSCompilerArguments::sourceMapEmbedSources, |
214 |
| - K2JSCompilerArguments::target, |
215 |
| - K2JSCompilerArguments::moduleKind, |
216 |
| - K2JSCompilerArguments::main, |
217 |
| - K2JSCompilerArguments::irModuleName, |
218 |
| - K2JSCompilerArguments::includes, |
219 |
| - K2JSCompilerArguments::friendModules, |
220 |
| - K2JSCompilerArguments::irDceRuntimeDiagnostic, |
221 |
| - ) |
222 |
| - private val k2JSCompilerArgumentsArrayProperties = commonCompilerArgumentsArrayProperties |
223 |
| - |
224 |
| - private fun assertContentEquals(expect: Collection<KProperty<*>>, actual: Collection<KProperty<*>>) { |
225 |
| - //assert(expect.count() == actual.count()) { |
226 |
| - // "Expected arguments count \"${expect.count()}\" doesn't match with actual \"${actual.count()}\"!" |
227 |
| - //} |
228 |
| - val processor: (Collection<KProperty<*>>) -> Collection<String> = { el -> el.map { it.name }.sorted() } |
229 |
| - assertEquals( |
230 |
| - processor(expect).joinToString("\n"), |
231 |
| - processor(actual).joinToString("\n") |
232 |
| - ) |
233 |
| - } |
234 |
| - } |
235 |
| -} |
0 commit comments