@@ -5,12 +5,17 @@ import com.saveourtool.save.core.plugin.ExtraFlagsExtractor
55import com.saveourtool.save.core.plugin.GeneralConfig
66import com.saveourtool.save.core.plugin.filterAndJoinBy
77import com.saveourtool.save.core.plugin.resolvePlaceholdersFrom
8+ import com.saveourtool.save.core.plugin.splitByNonEscaped
89
910import okio.fakefilesystem.FakeFileSystem
1011
1112import kotlin.test.Test
1213import kotlin.test.assertEquals
1314
15+ @Suppress(
16+ " TOO_LONG_FUNCTION" ,
17+ " WRONG_INDENTATION" , // issue in diktat
18+ )
1419class ExtraFlagsExtractorTest {
1520 @Test
1621 fun `basic test` () {
@@ -26,6 +31,9 @@ class ExtraFlagsExtractorTest {
2631 " Unparseable nonsense" to ExtraFlags .empty,
2732 " args1=--flag --opt,args2=-debug --flag2" to ExtraFlags (" --flag --opt" , " -debug --flag2" ),
2833 " args1=--flag\\ =value,args2=--foo=bar" to ExtraFlags (" --flag=value" , " --foo=bar" ),
34+ " args1=option1\\ ,option2,args2=option3\\ ,option4" to ExtraFlags (" option1,option2" , " option3,option4" ),
35+ " args1=option1\\ ,option2" to ExtraFlags (" option1,option2" , " " ),
36+ " args2=option3\\ ,option4" to ExtraFlags (" " , " option3,option4" ),
2937 )
3038 .forEach { (line, extraFlags) ->
3139 assertEquals(extraFlags, extraFlagsExtractor.extractExtraFlagsFrom(line))
@@ -105,6 +113,52 @@ class ExtraFlagsExtractorTest {
105113 " another-cmd --flag"
106114 )
107115 )
116+
117+ checkMultilineDirectives(
118+ Regex (""" // RUN: (.*([^\\]=)?.*)\\?""" ),
119+ listOf (
120+ " // RUN: command --flag=option\\ ,\\ " ,
121+ " // RUN: another-option --another-flag" ,
122+ " // RUN: another-cmd\\ =\\ " ,
123+ " // RUN: --flag=option\\ ,another-option" ,
124+ ),
125+ listOf (
126+ " command --flag=option\\ ,another-option --another-flag" ,
127+ " another-cmd\\ =--flag=option\\ ,another-option"
128+ )
129+ )
130+ }
131+
132+ @Test
133+ fun `test for splitByNonEscaped` () {
134+ assertEquals(
135+ listOf (" this string\\ , not split" ),
136+ " this string\\ , not split" .splitByNonEscaped(' ,' ),
137+ )
138+ assertEquals(
139+ listOf (" this string" , " but split" ),
140+ " this string, but split" .splitByNonEscaped(' ,' ),
141+ )
142+ assertEquals(
143+ listOf (" this string\\ , not split" , " but here - it's split" ),
144+ " this string\\ , not split, but here - it's split" .splitByNonEscaped(' ,' ),
145+ )
146+ assertEquals(
147+ listOf (" " , " " ),
148+ " ," .splitByNonEscaped(' ,' ),
149+ )
150+ assertEquals(
151+ listOf (" " , " text" ),
152+ " ,text" .splitByNonEscaped(' ,' ),
153+ )
154+ assertEquals(
155+ listOf (" \\ ," ),
156+ " \\ ," .splitByNonEscaped(' ,' ),
157+ )
158+ assertEquals(
159+ listOf (" \\ ,text" ),
160+ " \\ ,text" .splitByNonEscaped(' ,' ),
161+ )
108162 }
109163
110164 private fun checkMultilineDirectives (
0 commit comments