diff --git a/src/main/kotlin/org/move/cli/externalLinter/CompilerErrors.kt b/src/main/kotlin/org/move/cli/externalLinter/CompilerErrors.kt index bda6f1aa0..63a2e655b 100644 --- a/src/main/kotlin/org/move/cli/externalLinter/CompilerErrors.kt +++ b/src/main/kotlin/org/move/cli/externalLinter/CompilerErrors.kt @@ -41,7 +41,7 @@ private fun errorLinesToCompilerMessage(errorLines: List): AptosCompiler private val FILE_POSITION_RE = Regex("""┌─ (?(?:\p{Alpha}:)?[0-9a-z_A-Z\-\\./]+):(?[0-9]+):(?[0-9]+)""") private val ERROR_UNDERLINE_RE = - Regex("""^\s*│\s+-*\s*(?\^+)""") + Regex("""^\s*│[^\^]*(\^{2,})""") private fun splitSpans(errorLines: List): List { val filePositionMatch = @@ -50,7 +50,7 @@ private fun splitSpans(errorLines: List): List { val columnSpan = errorLines .firstNotNullOfOrNull { ERROR_UNDERLINE_RE.find(it) } ?.groupValues?.get(1) - ?.length ?: 0 + ?.length ?: 1 return listOf( AptosCompilerSpan( fileName, diff --git a/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt b/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt index ce7f07591..341160f46 100644 --- a/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt +++ b/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt @@ -72,14 +72,20 @@ class MvExternalLinterConfigurable(val project: Project): BoundConfigurable("Ext .comment("Adds code highlighting based on the external linter results. May affect the IDE performance") .bindSelected(state::runOnTheFly) } + separator() + row { + checkBox("Prevent duplicate errors") + .comment("Skips errors which are implemented by the IDE own analysis engine") + .bindSelected(state::skipErrorsKnownToIde) + } onApply { settings.modify { it.tool = state.tool it.additionalArguments = state.additionalArguments -// it.channel = state.channel it.envs = state.envs it.runOnTheFly = state.runOnTheFly + it.skipErrorsKnownToIde = state.skipErrorsKnownToIde } } } diff --git a/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterProjectSettingsService.kt b/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterProjectSettingsService.kt index 1644ce180..355fc8395 100644 --- a/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterProjectSettingsService.kt +++ b/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterProjectSettingsService.kt @@ -34,6 +34,7 @@ class MvExternalLinterProjectSettingsService( // val channel: RustChannel get() = state.channel val envs: Map get() = state.envs val runOnTheFly: Boolean get() = state.runOnTheFly + val skipErrorsKnownToIde: Boolean get() = state.skipErrorsKnownToIde class MvExternalLinterProjectSettings: MvProjectSettingsBase() { @AffectsHighlighting @@ -49,6 +50,8 @@ class MvExternalLinterProjectSettingsService( @AffectsHighlighting var runOnTheFly by property(false) + @AffectsHighlighting + var skipErrorsKnownToIde by property(false) override fun copy(): MvExternalLinterProjectSettings { val state = MvExternalLinterProjectSettings() diff --git a/src/main/kotlin/org/move/cli/runConfigurations/BlockchainCli.kt b/src/main/kotlin/org/move/cli/runConfigurations/BlockchainCli.kt index 8473b62c4..d0192ff50 100644 --- a/src/main/kotlin/org/move/cli/runConfigurations/BlockchainCli.kt +++ b/src/main/kotlin/org/move/cli/runConfigurations/BlockchainCli.kt @@ -95,7 +95,7 @@ sealed class BlockchainCli { return Ok(Unit) } - fun compileProject( + fun checkProject( project: Project, owner: Disposable, args: AptosCompileArgs @@ -103,19 +103,26 @@ sealed class BlockchainCli { // val useClippy = args.linter == ExternalLinter.CLIPPY // && !checkNeedInstallClippy(project, args.cargoProjectDirectory) // val checkCommand = if (useClippy) "clippy" else "check" - val arguments = buildList { -// add("--message-format=json") -// add("--all") -// if (args.allTargets && checkSupportForBuildCheckAllTargets()) { -// add("--all-targets") -// } - add("compile") - addAll(ParametersListUtil.parse(args.extraArguments)) - } + val extraArguments = ParametersListUtil.parse(args.extraArguments) val cliArgs = CliCommandLineArgs( "move", - arguments, + buildList { +// add("--message-format=json") + add("compile") + if ("--skip-fetch-latest-git-deps" !in extraArguments) { + add("--skip-fetch-latest-git-deps") + } + if (args.isCompilerV2 && "--compiler-version" !in extraArguments) { + add("--compiler-version") + add("v2") + } + if (args.isCompilerV2 && "--language-version" !in extraArguments) { + add("--language-version") + add("2.0") + } + addAll(ParametersListUtil.parse(args.extraArguments)) + }, args.moveProjectDirectory, environmentVariables = EnvironmentVariablesData.create(args.envs, true) ) @@ -190,17 +197,22 @@ data class AptosCompileArgs( val moveProjectDirectory: Path, val extraArguments: String, val envs: Map, + val isCompilerV2: Boolean, + val skipLatestGitDeps: Boolean, ) { companion object { fun forMoveProject(moveProject: MoveProject): AptosCompileArgs { - val settings = moveProject.project.externalLinterSettings + val linterSettings = moveProject.project.externalLinterSettings + val moveSettings = moveProject.project.moveSettings return AptosCompileArgs( - settings.tool, + linterSettings.tool, moveProject.workingDirectory, // moveProject.project.rustSettings.compileAllTargets, - settings.additionalArguments, + linterSettings.additionalArguments, // settings.channel, - settings.envs + linterSettings.envs, + isCompilerV2 = moveSettings.isCompilerV2, + skipLatestGitDeps = moveSettings.skipFetchLatestGitDeps ) } } diff --git a/src/main/kotlin/org/move/cli/settings/MvProjectSettingsService.kt b/src/main/kotlin/org/move/cli/settings/MvProjectSettingsService.kt index 12f1723c5..3a3aaaf4a 100644 --- a/src/main/kotlin/org/move/cli/settings/MvProjectSettingsService.kt +++ b/src/main/kotlin/org/move/cli/settings/MvProjectSettingsService.kt @@ -7,7 +7,6 @@ import com.intellij.openapi.components.StoragePathMacros import com.intellij.openapi.components.service import com.intellij.openapi.project.Project import com.intellij.openapi.util.registry.Registry -import com.intellij.psi.PsiManager import org.move.cli.runConfigurations.BlockchainCli import org.move.cli.runConfigurations.BlockchainCli.Aptos import org.move.cli.runConfigurations.BlockchainCli.Sui @@ -65,7 +64,6 @@ class MvProjectSettingsService( val fetchAptosDeps: Boolean get() = state.fetchAptosDeps val disableTelemetry: Boolean get() = state.disableTelemetry - val foldSpecs: Boolean get() = state.foldSpecs val skipFetchLatestGitDeps: Boolean get() = state.skipFetchLatestGitDeps val dumpStateOnTestFailure: Boolean get() = state.dumpStateOnTestFailure @@ -89,7 +87,6 @@ class MvProjectSettingsService( @AffectsMoveProjectsMetadata var fetchAptosDeps: Boolean by property(false) - var foldSpecs: Boolean by property(false) var disableTelemetry: Boolean by property(true) // change to true here to not annoy the users with constant updates @@ -103,14 +100,6 @@ class MvProjectSettingsService( } } - override fun notifySettingsChanged(event: SettingsChangedEventBase) { - super.notifySettingsChanged(event) - - if (event.isChanged(MoveProjectSettings::foldSpecs)) { - PsiManager.getInstance(project).dropPsiCaches() - } - } - override fun createSettingsChangedEvent( oldEvent: MoveProjectSettings, newEvent: MoveProjectSettings @@ -124,7 +113,7 @@ class MvProjectSettingsService( companion object { private val defaultAptosExecType get() = - if (AptosExecType.isPreCompiledSupportedForThePlatform) AptosExecType.BUNDLED else AptosExecType.LOCAL; + if (AptosExecType.isPreCompiledSupportedForThePlatform) AptosExecType.BUNDLED else AptosExecType.LOCAL } } diff --git a/src/main/kotlin/org/move/cli/settings/PerProjectMoveConfigurable.kt b/src/main/kotlin/org/move/cli/settings/PerProjectMoveConfigurable.kt index 759eeff84..38c0bb002 100644 --- a/src/main/kotlin/org/move/cli/settings/PerProjectMoveConfigurable.kt +++ b/src/main/kotlin/org/move/cli/settings/PerProjectMoveConfigurable.kt @@ -45,10 +45,6 @@ class PerProjectMoveConfigurable(val project: Project): BoundConfigurable("Move .visibleIf(suiRadioButton!!.selected) } group { - row { - checkBox("Auto-fold specs in opened files") - .bindSelected(state::foldSpecs) - } row { checkBox("Disable telemetry for new Run Configurations") .bindSelected(state::disableTelemetry) @@ -107,7 +103,6 @@ class PerProjectMoveConfigurable(val project: Project): BoundConfigurable("Move it.localSuiPath = chooseSuiCliPanel.data.localSuiPath it.blockchain = state.blockchain - it.foldSpecs = state.foldSpecs it.disableTelemetry = state.disableTelemetry it.skipFetchLatestGitDeps = state.skipFetchLatestGitDeps it.dumpStateOnTestFailure = state.dumpStateOnTestFailure diff --git a/src/main/kotlin/org/move/cli/settings/aptos/ChooseAptosCliPanel.kt b/src/main/kotlin/org/move/cli/settings/aptos/ChooseAptosCliPanel.kt index 9fae4efea..d17a82ba9 100644 --- a/src/main/kotlin/org/move/cli/settings/aptos/ChooseAptosCliPanel.kt +++ b/src/main/kotlin/org/move/cli/settings/aptos/ChooseAptosCliPanel.kt @@ -106,6 +106,8 @@ class ChooseAptosCliPanel(versionUpdateListener: (() -> Unit)?): Disposable { private val downloadPrecompiledBinaryAction = DownloadAptosSDKAction().also { it.onFinish = { sdk -> + bundledRadioButton.isSelected = false + localRadioButton.isSelected = true localPathField.text = sdk.targetFile.toString() updateVersion() } @@ -162,7 +164,6 @@ class ChooseAptosCliPanel(versionUpdateListener: (() -> Unit)?): Disposable { .resizableColumn() if (popupActionGroup.childrenCount != 0) { cell(getAptosActionLink) - .enabledIf(localRadioButton.selected) } } row("--version :") { cell(versionLabel) } diff --git a/src/main/kotlin/org/move/ide/annotator/RsExternalLinterUtils.kt b/src/main/kotlin/org/move/ide/annotator/RsExternalLinterUtils.kt index 5770debbf..e4d847c45 100644 --- a/src/main/kotlin/org/move/ide/annotator/RsExternalLinterUtils.kt +++ b/src/main/kotlin/org/move/ide/annotator/RsExternalLinterUtils.kt @@ -26,11 +26,13 @@ import com.intellij.util.messages.MessageBus import org.apache.commons.lang3.StringEscapeUtils import org.jetbrains.annotations.Nls import org.move.cli.externalLinter.RsExternalLinterWidget +import org.move.cli.externalLinter.externalLinterSettings import org.move.cli.externalLinter.parseCompilerErrors import org.move.cli.runConfigurations.AptosCompileArgs import org.move.cli.runConfigurations.BlockchainCli.Aptos import org.move.ide.annotator.RsExternalLinterFilteredMessage.Companion.filterMessage import org.move.ide.annotator.RsExternalLinterUtils.TEST_MESSAGE +import org.move.ide.notifications.logOrShowBalloon import org.move.lang.MoveFile import org.move.openapiext.ProjectCache import org.move.openapiext.checkReadAccessAllowed @@ -108,7 +110,7 @@ object RsExternalLinterUtils { override fun run(indicator: ProgressIndicator) { widget?.inProgress = true - future.complete(check(aptosCli, project, owner, workingDirectory, args)) + future.complete(check(aptosCli, project, owner, args)) } override fun onFinished() { @@ -123,13 +125,12 @@ object RsExternalLinterUtils { aptosCli: Aptos, project: Project, owner: Disposable, - workingDirectory: Path, args: AptosCompileArgs ): RsExternalLinterResult? { ProgressManager.checkCanceled() val started = Instant.now() val output = aptosCli - .compileProject(project, owner, args) + .checkProject(project, owner, args) .unwrapOrElse { e -> LOG.error(e) return null @@ -137,7 +138,10 @@ object RsExternalLinterUtils { val finish = Instant.now() ProgressManager.checkCanceled() if (output.isCancelled) return null - return RsExternalLinterResult(output.stdoutLines, Duration.between(started, finish).toMillis()) + return RsExternalLinterResult( + output.stderrLines + output.stdoutLines, + Duration.between(started, finish).toMillis() + ) } private data class Key( @@ -178,8 +182,9 @@ fun MutableList.addHighlightsForFile( val doc = file.viewProvider.document ?: error("Can't find document for $file in external linter") + val skipIdeErrors = file.project.externalLinterSettings.skipErrorsKnownToIde val filteredMessages = annotationResult.messages - .mapNotNull { message -> filterMessage(file, doc, message) } + .mapNotNull { message -> filterMessage(file, doc, message, skipIdeErrors) } // Cargo can duplicate some error messages when `--all-targets` attribute is used .distinct() for (message in filteredMessages) { @@ -232,15 +237,18 @@ private data class RsExternalLinterFilteredMessage( // val quickFixes: List ) { companion object { + private val LOG = logger() + fun filterMessage( file: PsiFile, document: Document, - message: AptosCompilerMessage + message: AptosCompilerMessage, + skipErrorsKnownToIde: Boolean, ): RsExternalLinterFilteredMessage? { + println(message) // if (message.message.startsWith("aborting due to") || message.message.startsWith("cannot continue")) { // return null // } - val severity = when (message.severityLevel) { "error" -> HighlightSeverity.ERROR "warning" -> HighlightSeverity.WEAK_WARNING @@ -251,11 +259,28 @@ private data class RsExternalLinterFilteredMessage( // but they look rather ugly, so just skip them. val span = message.mainSpan ?: return null - val syntaxErrors = listOf("expected pattern", "unexpected token") + // drop syntax errors + val syntaxErrors = listOf("unexpected token") +// val syntaxErrors = listOf("expected pattern", "unexpected token") if (syntaxErrors.any { it in span.label.orEmpty() || it in message.message }) { return null } + if (skipErrorsKnownToIde) { + val errorsToIgnore = listOf( + // name resolution errors + "unbound variable", "undeclared", + // type errors + "incompatible types", "which expects a value of type", + // too many arguments + "too many arguments", "the function takes", + ) + if (errorsToIgnore.any { it in message.message }) { + LOG.logOrShowBalloon("ignore compiler error: ${message.toTestString()}") + return null + } + } + val spanFilePath = PathUtil.toSystemIndependentName(span.filename) if (!file.virtualFile.path.endsWith(spanFilePath)) return null diff --git a/src/main/kotlin/org/move/ide/folding/MvFoldingBuilder.kt b/src/main/kotlin/org/move/ide/folding/MvFoldingBuilder.kt index d77d9e2b3..b01a4ec29 100644 --- a/src/main/kotlin/org/move/ide/folding/MvFoldingBuilder.kt +++ b/src/main/kotlin/org/move/ide/folding/MvFoldingBuilder.kt @@ -14,7 +14,6 @@ import com.intellij.psi.PsiWhiteSpace import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.elementType import com.intellij.psi.util.nextLeaf -import org.move.cli.settings.moveSettings import org.move.lang.MoveFile import org.move.lang.MoveParserDefinition.Companion.BLOCK_COMMENT import org.move.lang.MoveParserDefinition.Companion.EOL_DOC_COMMENT @@ -22,7 +21,7 @@ import org.move.lang.MvElementTypes.* import org.move.lang.core.psi.* import org.move.lang.core.psi.ext.* -class MvFoldingBuilder : CustomFoldingBuilder(), DumbAware { +class MvFoldingBuilder: CustomFoldingBuilder(), DumbAware { override fun getLanguagePlaceholderText(node: ASTNode, range: TextRange): String { when (node.elementType) { L_BRACE -> return " { " @@ -54,17 +53,15 @@ class MvFoldingBuilder : CustomFoldingBuilder(), DumbAware { PsiTreeUtil.processElements(root) { it.accept(visitor); true } } - override fun isRegionCollapsedByDefault(node: ASTNode): Boolean { - return node.psi.project.moveSettings.foldSpecs && node.elementType == MODULE_SPEC_BLOCK - || CodeFoldingSettings.getInstance().isDefaultCollapsedNode(node) - } + override fun isRegionCollapsedByDefault(node: ASTNode): Boolean = + CodeFoldingSettings.getInstance().isDefaultCollapsedNode(node) private class FoldingVisitor( private val descriptors: MutableList, private val usesRanges: MutableList, private val constRanges: MutableList, private val docCommentRanges: MutableList, - ) : MvVisitor() { + ): MvVisitor() { override fun visitCodeBlock(o: MvCodeBlock) = fold(o) override fun visitScriptBlock(o: MvScriptBlock) = fold(o) diff --git a/src/main/kotlin/org/move/ide/notifications/Utils.kt b/src/main/kotlin/org/move/ide/notifications/Utils.kt index 56ddf4daf..5e827a43a 100644 --- a/src/main/kotlin/org/move/ide/notifications/Utils.kt +++ b/src/main/kotlin/org/move/ide/notifications/Utils.kt @@ -6,6 +6,7 @@ import com.intellij.notification.Notifications import com.intellij.openapi.Disposable import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.LogLevel import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project import com.intellij.openapi.ui.MessageType @@ -16,15 +17,19 @@ import com.intellij.openapi.util.NlsContexts.NotificationTitle import com.intellij.ui.awt.RelativePoint import org.move.cli.settings.isDebugModeEnabled import org.move.openapiext.common.isUnitTestMode +import org.move.openapiext.log import java.awt.Component import java.awt.Point import javax.swing.event.HyperlinkListener -fun Logger.logOrShowBalloon(@NotificationContent content: String) { +fun Logger.logOrShowBalloon(@NotificationContent content: String, productionLevel: LogLevel = LogLevel.DEBUG) { when { - isUnitTestMode -> this.warn(content) - isDebugModeEnabled() -> showBalloonWithoutProject(content, INFORMATION) - else -> this.debug(content) + isUnitTestMode -> this.warn("BALLOON: $content") + isDebugModeEnabled() -> { + this.warn(content) + showBalloonWithoutProject(content, INFORMATION) + } + else -> this.log(content, productionLevel) } } @@ -85,3 +90,12 @@ fun showBalloonWithoutProject( val notification = MvNotifications.pluginNotifications().createNotification(content, type) Notifications.Bus.notify(notification) } + +fun showBalloonWithoutProject( + title: String, + @NotificationContent content: String, + type: NotificationType +) { + val notification = MvNotifications.pluginNotifications().createNotification(title, content, type) + Notifications.Bus.notify(notification) +} diff --git a/src/main/kotlin/org/move/openapiext/CommandLineExt.kt b/src/main/kotlin/org/move/openapiext/CommandLineExt.kt index 73e2c4565..e79b218e0 100644 --- a/src/main/kotlin/org/move/openapiext/CommandLineExt.kt +++ b/src/main/kotlin/org/move/openapiext/CommandLineExt.kt @@ -9,6 +9,7 @@ import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.process.CapturingProcessHandler import com.intellij.execution.process.ProcessListener import com.intellij.execution.process.ProcessOutput +import com.intellij.notification.NotificationType.INFORMATION import com.intellij.openapi.Disposable import com.intellij.openapi.application.runReadAction import com.intellij.openapi.diagnostic.Logger @@ -17,6 +18,8 @@ import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.util.Disposer import com.intellij.util.io.systemIndependentPath import org.move.cli.runConfigurations.MvCapturingProcessHandler +import org.move.cli.settings.isDebugModeEnabled +import org.move.ide.notifications.showBalloonWithoutProject import org.move.stdext.RsResult import org.move.stdext.unwrapOrElse import java.nio.file.Path @@ -53,6 +56,8 @@ fun GeneralCommandLine.execute(): ProcessOutput? { return null } val output = handler.runProcessWithGlobalProgress() + showCommandLineBalloon(commandLineString, output) + if (!output.isSuccess) { LOG.warn(RsProcessExecutionException.errorMessage(commandLineString, output)) } @@ -119,6 +124,7 @@ fun GeneralCommandLine.execute( } finally { Disposer.dispose(processKiller) } + showCommandLineBalloon(commandLineString, output) return when { output.isCancelled -> RsResult.Err(RsProcessExecutionException.Canceled(commandLineString, output)) @@ -133,6 +139,19 @@ fun GeneralCommandLine.execute( } } +private fun showCommandLineBalloon(commandLineString: String, output: ProcessOutput) { + if (isDebugModeEnabled()) { + val content = + if (!output.isSuccess) { + """`$commandLineString` |Execution failed (exit code ${output.exitCode}). + """ + } else { + """`$commandLineString` |Execution successful. + """ + } + showBalloonWithoutProject(content.trimStart(), INFORMATION) + } +} private fun errorMessage(commandLine: GeneralCommandLine, output: ProcessOutput): String = """ |Execution failed (exit code ${output.exitCode}). diff --git a/src/main/kotlin/org/move/openapiext/Logger.kt b/src/main/kotlin/org/move/openapiext/Logger.kt index 2369eea7f..c180965a4 100644 --- a/src/main/kotlin/org/move/openapiext/Logger.kt +++ b/src/main/kotlin/org/move/openapiext/Logger.kt @@ -1,5 +1,7 @@ package org.move.openapiext +import com.intellij.openapi.diagnostic.LogLevel +import com.intellij.openapi.diagnostic.LogLevel.* import com.intellij.openapi.diagnostic.Logger import org.move.openapiext.common.isUnitTestMode @@ -10,3 +12,14 @@ fun Logger.debugInProduction(message: String) { this.debug(message) } } + +fun Logger.log(content: String, level: LogLevel) { + when (level) { + ERROR -> this.error(content) + WARNING -> this.warn(content) + INFO -> this.info(content) + DEBUG -> this.debug(content) + TRACE -> this.trace(content) + OFF, ALL -> {} + } +} \ No newline at end of file diff --git a/src/test/kotlin/org/move/cli/externalLinter/CompilerErrorsTest.kt b/src/test/kotlin/org/move/cli/externalLinter/CompilerErrorsTest.kt index 0d9acf7a0..c5f3f42e1 100644 --- a/src/test/kotlin/org/move/cli/externalLinter/CompilerErrorsTest.kt +++ b/src/test/kotlin/org/move/cli/externalLinter/CompilerErrorsTest.kt @@ -173,6 +173,91 @@ error[E04007]: incompatible types ) ) + fun `test ability not satisfied`() = doTest(""" +Compiling, may take a little while to download git dependencies... +UPDATING GIT DEPENDENCY https://github.com/aptos-labs/aptos-core.git +INCLUDING DEPENDENCY AptosFramework +INCLUDING DEPENDENCY AptosStdlib +INCLUDING DEPENDENCY MoveStdlib +BUILDING move-test-location-example +error[E05001]: ability constraint not satisfied + ┌─ /tmp/main/sources/main.move:5:9 + │ +2 │ struct S has key { field: u8 } + │ - To satisfy the constraint, the 'drop' ability would need to be added here +3 │ +4 │ fun test_assert_false(s: S) { + │ - The type '0x1::main2::S' does not have the ability 'drop' +5 │ s; + │ ^ Cannot ignore values without the 'drop' ability. The value must be used + +{ + "Error": "Move compilation failed: Compilation error" +} + """, listOf( + AptosCompilerMessage.forTest( + message = "ability constraint not satisfied", + severityLevel = "error", + filename = "/tmp/main/sources/main.move", + location = "[(5, 9), (5, 10)]" + ) + ) + ) + + fun `test ability not satisfied compiler v2`() = doTest(""" +Warning: compiler version `2.0-unstable` is experimental and should not be used in production +Compiling, may take a little while to download git dependencies... +UPDATING GIT DEPENDENCY https://github.com/aptos-labs/aptos-core.git +INCLUDING DEPENDENCY AptosFramework +INCLUDING DEPENDENCY AptosStdlib +INCLUDING DEPENDENCY MoveStdlib +BUILDING move-test-location-example +error: value of type `main2::S` does not have the `drop` ability + ┌─ /tmp/main/sources/main2.move:5:9 + │ +5 │ s; + │ ^ implicitly dropped here since it is no longer used + +{ + "Error": "Move compilation failed: exiting with stackless-bytecode analysis errors" +} + """, listOf( + AptosCompilerMessage.forTest( + message = "value of type `main2::S` does not have the `drop` ability", + severityLevel = "error", + filename = "/tmp/main/sources/main2.move", + location = "[(5, 9), (5, 10)]" + ) + ) + ) + + fun `test too many params`() = doTest(""" +Warning: compiler version `2.0-unstable` is experimental and should not be used in production +Warning: language version `2.0-unstable` is experimental and should not be used in production +Compiling, may take a little while to download git dependencies... +INCLUDING DEPENDENCY AptosFramework +INCLUDING DEPENDENCY AptosStdlib +INCLUDING DEPENDENCY MoveStdlib +BUILDING move-test-location-example +error: the function takes 0 arguments but 2 were provided + ┌─ /home/mkurnikov/code/move-test-location-example/sources/main2.move:7:9 + │ +7 │ test_assert_false(1, 2); + │ ^^^^^^^^^^^^^^^^^^^^^^^ + +{ + "Error": "Move compilation failed: exiting with checking errors" +} + """, listOf( + AptosCompilerMessage.forTest( + message = "the function takes 0 arguments but 2 were provided", + severityLevel = "error", + filename = "/home/mkurnikov/code/move-test-location-example/sources/main2.move", + location = "[(7, 9), (7, 32)]" + ) + ) + ) + private fun doTest(compilerOutput: String, expectedMessages: List) { val messages = parseCompilerErrors(compilerOutput.trimIndent().lines())