Skip to content

Commit c17a90c

Browse files
authored
feat(acton): add --backtrace full option to test runner (#791)
1 parent 066f5f6 commit c17a90c

6 files changed

Lines changed: 37 additions & 23 deletions

File tree

modules/acton/src/org/ton/intellij/acton/cli/ActonCommand.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ sealed class ActonCommand(val name: String) {
7272
var clearCache: Boolean = false,
7373
var useColors: Boolean = false,
7474
var ui: Boolean = false,
75+
var backtraceFull: Boolean = false,
7576
var debug: Boolean = false,
7677
var debugPort: String = "",
7778
) : ActonCommand("test") {
@@ -86,6 +87,10 @@ sealed class ActonCommand(val name: String) {
8687
add("always")
8788
}
8889
if (ui) add("--ui")
90+
if (backtraceFull) {
91+
add("--backtrace")
92+
add("full")
93+
}
8994
if (debug) {
9095
add("--debug")
9196
if (debugPort.isNotBlank()) {

modules/acton/src/org/ton/intellij/acton/ide/ActonBacktraceRerunLauncher.kt

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object ActonBacktraceRerunLauncher {
2424
)
2525
val configuration = settings.configuration as ActonCommandConfiguration
2626
configuration.copyFrom(sourceConfiguration)
27-
configuration.parameters = withBacktraceFull(sourceConfiguration.parameters)
27+
configuration.testBacktraceFull = true
2828

2929
failedTestName?.trim()?.takeIf { it.isNotBlank() }?.let { testName ->
3030
configuration.testMode = org.ton.intellij.acton.cli.ActonCommand.Test.TestMode.FUNCTION
@@ -38,28 +38,8 @@ object ActonBacktraceRerunLauncher {
3838
return true
3939
}
4040

41-
internal fun withBacktraceFull(parameters: String): String {
42-
val trimmed = parameters.trim()
43-
if (trimmed.isBlank()) {
44-
return "--backtrace full"
45-
}
46-
if (FULL_BACKTRACE_REGEX.containsMatchIn(trimmed)) {
47-
return trimmed
48-
}
49-
if (BACKTRACE_REGEX.containsMatchIn(trimmed)) {
50-
return BACKTRACE_REGEX.replace(trimmed) { match ->
51-
val prefix = match.groups[1]?.value.orEmpty()
52-
"$prefix--backtrace full"
53-
}
54-
}
55-
return "$trimmed --backtrace full"
56-
}
57-
5841
private fun buildConfigurationName(configuration: ActonCommandConfiguration, failedTestName: String?): String {
5942
val suffix = failedTestName?.takeIf { it.isNotBlank() }?.let { " [$it backtrace]" } ?: " [backtrace]"
6043
return configuration.name + suffix
6144
}
62-
63-
private val FULL_BACKTRACE_REGEX = Regex("""(?:^|\s)--backtrace\s+full(?:\s|$)""")
64-
private val BACKTRACE_REGEX = Regex("""(^|\s)--backtrace\s+\S+(?=\s|$)""")
6545
}

modules/acton/src/org/ton/intellij/acton/runconfig/ActonCommandConfiguration.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ActonCommandConfiguration(project: Project, factory: ConfigurationFactory,
4242
var testFunctionName: String = ""
4343
var testClearCache: Boolean = false
4444
var testUi: Boolean = false
45+
var testBacktraceFull: Boolean = false
4546

4647
// Run command specific settings (Acton.toml scripts)
4748
var runScriptName: String = ""
@@ -58,7 +59,15 @@ class ActonCommandConfiguration(project: Project, factory: ConfigurationFactory,
5859
scriptBroadcastNet, project.actonSettings.explorer.id, scriptDebug, scriptDebugPort,
5960
)
6061

61-
"test" -> ActonCommand.Test(testMode, testTarget, testFunctionName, testClearCache, true, testUi)
62+
"test" -> ActonCommand.Test(
63+
testMode,
64+
testTarget,
65+
testFunctionName,
66+
testClearCache,
67+
true,
68+
testUi,
69+
testBacktraceFull,
70+
)
6271
"init" -> ActonCommand.Init()
6372
"run" -> ActonCommand.Run(runScriptName)
6473
"retrace" -> ActonCommand.Retrace(retraceTransactionHash, retraceNetwork, retraceContractId)
@@ -99,6 +108,7 @@ class ActonCommandConfiguration(project: Project, factory: ConfigurationFactory,
99108
element.setAttribute("testFunctionName", testFunctionName)
100109
element.setAttribute("testClearCache", testClearCache.toString())
101110
element.setAttribute("testUi", testUi.toString())
111+
element.setAttribute("testBacktraceFull", testBacktraceFull.toString())
102112

103113
// Run settings
104114
element.setAttribute("runScriptName", runScriptName)
@@ -141,6 +151,7 @@ class ActonCommandConfiguration(project: Project, factory: ConfigurationFactory,
141151
testFunctionName = element.getAttributeValue("testFunctionName") ?: ""
142152
testClearCache = element.getAttributeValue("testClearCache")?.toBoolean() ?: false
143153
testUi = element.getAttributeValue("testUi")?.toBoolean() ?: false
154+
testBacktraceFull = element.getAttributeValue("testBacktraceFull")?.toBoolean() ?: false
144155

145156
// Run settings
146157
runScriptName = element.getAttributeValue("runScriptName") ?: ""
@@ -178,6 +189,7 @@ class ActonCommandConfiguration(project: Project, factory: ConfigurationFactory,
178189
testFunctionName = other.testFunctionName
179190
testClearCache = other.testClearCache
180191
testUi = other.testUi
192+
testBacktraceFull = other.testBacktraceFull
181193

182194
runScriptName = other.runScriptName
183195

modules/acton/src/org/ton/intellij/acton/runconfig/ActonCommandConfigurationEditor.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class ActonCommandConfigurationEditor(private val project: Project) : SettingsEd
5656
private val testFunctionNameField = JBTextField()
5757
private val testClearCacheCheckBox = JBCheckBox("Clear compilation cache before testing", false)
5858
private val testUiCheckBox = JBCheckBox("Open browser UI", false)
59+
private val testBacktraceFullCheckBox = JBCheckBox("Run tests with full execution backtrace", false)
5960
private var testMode: ActonCommand.Test.TestMode = ActonCommand.Test.TestMode.DIRECTORY
6061

6162
// Run specific
@@ -227,6 +228,7 @@ class ActonCommandConfigurationEditor(private val project: Project) : SettingsEd
227228
testFunctionNameField.text = configuration.testFunctionName
228229
testClearCacheCheckBox.isSelected = configuration.testClearCache
229230
testUiCheckBox.isSelected = configuration.testUi
231+
testBacktraceFullCheckBox.isSelected = configuration.testBacktraceFull
230232

231233
runScriptNameField.text = configuration.runScriptName
232234

@@ -264,6 +266,7 @@ class ActonCommandConfigurationEditor(private val project: Project) : SettingsEd
264266
configuration.testFunctionName = testFunctionNameField.text.trim()
265267
configuration.testClearCache = testClearCacheCheckBox.isSelected
266268
configuration.testUi = testUiCheckBox.isSelected
269+
configuration.testBacktraceFull = testBacktraceFullCheckBox.isSelected
267270

268271
configuration.runScriptName = runScriptNameField.text.trim()
269272

@@ -338,6 +341,10 @@ class ActonCommandConfigurationEditor(private val project: Project) : SettingsEd
338341
row {
339342
cell(testUiCheckBox)
340343
}.topGap(TopGap.NONE)
344+
345+
row {
346+
cell(testBacktraceFullCheckBox)
347+
}.topGap(TopGap.NONE)
341348
}.topGap(TopGap.NONE)
342349

343350
runGroup = group("Run arguments") {

modules/acton/test/org/ton/intellij/acton/cli/ActonCommandTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,15 @@ class ActonCommandTest {
2727
ActonCommand.from("init", "--create-dapp"),
2828
)
2929
}
30+
31+
@Test
32+
fun `test command includes full backtrace flag`() {
33+
assertEquals(
34+
listOf("--reporter", "console,teamcity", "--backtrace", "full", "."),
35+
ActonCommand.Test(
36+
target = ".",
37+
backtraceFull = true,
38+
).getArguments(),
39+
)
40+
}
3041
}

modules/tolk/src/org/ton/intellij/tolk/ide/fixes/TolkCreateLocalVariableQuickfix.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.ton.intellij.tolk.ide.fixes
22

3-
import com.intellij.codeInsight.intention.HighPriorityAction
43
import com.intellij.codeInsight.template.TemplateManager
54
import com.intellij.codeInsight.template.impl.ConstantNode
65
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement

0 commit comments

Comments
 (0)