Skip to content

Commit 09aad38

Browse files
authored
Convert --language option to String instead of LanguageType (#444)
* Convert --language option to String instead of LanguageType * Improve docs of extra flags feature
1 parent 6c7c3d8 commit 09aad38

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

OptionsTable.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ Most (except for `-h` and `-prop`) of the options below can be passed to a SAVE
1010
| b | baseline | Path to the file with baseline data | - |
1111
| e | exclude-suites | Test suites, which won't be checked | - |
1212
| i | include-suites | Test suites, only which ones will be checked | - |
13-
| l | language | Language that you are developing analyzer for | UNDEFINED |
13+
| l | language | Language that you are developing analyzer for | - |
1414
| out | result-output | Data output stream | STDOUT |
1515
| - | report-dir | Path to directory, where to store output (when `resultOutput` is set to `FILE`) | save-reports |

buildSrc/src/main/resources/config-options.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
"default" : null
5757
},
5858
"language" : {
59-
"argType" : "ArgType.Choice<LanguageType>()",
60-
"kotlinType": "com.saveourtool.save.core.config.LanguageType",
59+
"argType" : "ArgType.String",
60+
"kotlinType": "kotlin.String",
6161
"fullName" : "language",
6262
"shortName" : "l",
6363
"description" : "Language that you are developing analyzer for",
64-
"default" : "LanguageType.UNDEFINED"
64+
"default" : null
6565
},
6666
"resultOutput" : {
6767
"argType" : "ArgType.Choice<OutputStreamType>()",

save-common/src/commonMain/kotlin/com/saveourtool/save/core/config/LanguageType.kt

-18
This file was deleted.

save-plugins/warn-plugin/README.md

+20-6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ patternForRegexInWarning = ["{{", "}}"]
131131
partialWarnTextMatch = false # (default value)
132132
# if not set than stdout will be used as result of warn plugin execution
133133
testToolResFileOutput = "result.out" # (no default value is set)
134+
135+
# Extra flags will be extracted from a line that mathces this regex if it's present in a file
136+
runConfigPattern = "# RUN: (.+)"
134137
```
135138

136139
When executed from project root (where `save.propertes` is located), SAVE will cd to `rootDir` and discover all files
@@ -146,22 +149,33 @@ with `lineCaptureGroup`, `columnCaptureGroup` and `messageCaptureGroup` paramete
146149
usually you'll want them to be consistent to make testing easier, i.e. if input has line number, then so should output.
147150
`testNameRegex` is a regular expression which sets the name of the test file.
148151

149-
### Customize `execCmd` per file with placefolders and execFlags
152+
### Customize `execCmd` per file with placeholders and execFlags
150153
As the next level of customization, execution command can be customized per individual test. To do so, one can use a special comment in that file.
151154
The pattern of the comment is taken from `WarnPluginConfig.runConfigPattern`. It should contain a single capture group, which corresponds to
152-
execution command.
155+
execution command. Capturing of multiline commands is supported; in this case the line should be finalized by `\`.
153156

154157
Additionally, that execution command can define a number of placeholders, which can be used in `execFlags` in TOML config:
155158
* `args1` a set of CLI parameters which will be inserted _between_ `execFlags` from TOML config and name of the test file
156159
* `args2` a set of CLI parameters which will be inserted _after_ the name of the test file
157-
These placeholders are optional; if present, they should be comma-separated. Equal sign can be escaped with `\`. They can be accessed
158-
from `warn.execFlags` with `$` sign. Additionally, `$fileName` in `execFlags` is substituted by the name of analyzed file
160+
These placeholders are optional; if present, they should be comma-separated. Comma and equal sign can be escaped with `\`.
161+
They can be accessed from `warn.execFlags` with `$` sign. Additionally, `$fileName` in `execFlags` is substituted by the name of analyzed file
159162
(or a set of names in batch mode).
160163

161-
For example, the comment `// RUN: args1=--foo\=bar,args2=--log debug` in combination with `warn.execCmd = ./my-tool` will lead to execution
164+
For example, the comment `// RUN: args1=--foo\=bar,args2=--baz=opt-1\,opt-2` in combination with `warn.execCmd = ./my-tool` will lead to execution
162165
of the following command when checking file `FileName`:
163166
```bash
164-
./my-tool --foo=bar FileName --log debug
167+
./my-tool --foo=bar FileName --baz=opt-1,opt-2
168+
```
169+
170+
More examples:
171+
```c++
172+
// RUN: args1=--log debug\
173+
// RUN: args2=--verbose --verbosity=4 \
174+
// RUN: --output out.txt
175+
```
176+
translates to
177+
```bash
178+
./my-tool --log debug FileName --verbose --verbosity=4 --output out.txt
165179
```
166180

167181
The following images explain how `execFlags` can be used:

0 commit comments

Comments
 (0)