CONTEXT
I'm trying to use Visual Studio Code's (VSCode) tasks (tasks.json) and better understand how the problemMatcher settings work or if they work at all.
For this purpose, I've created the following setup in Visual Studio Code (VSCode) to test...
NOTES:
I - The official documentation for Visual Studio Code (VSCode) didn't help me much in understanding this functionality.
II - The information about Python is for illustrative purposes only.
III - The Bash scripts simulate operations that are intended to be performed, and they handle error situations.
FILES
test-vscode-tasks
.vscode
launch.json
tasks.json
.debug
build.bash
start.bash
stop.bash
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debug",
"type": "python",
"request": "attach",
"port": 5890,
"host": "127.0.0.1",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/var/task"
}
],
"preLaunchTask": "start",
"postDebugTask": "stop"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "bash ${workspaceFolder}/.debug/build.bash",
"isBackground": true,
"problemMatcher": [
{
"pattern": [
{
"regexp": "\\b\\B",
"file": 1,
"location": 2,
"message":3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^.*BUILD*",
"endsPattern": "^.*ERROR*"
}
}
],
"presentation": {
"reveal": "silent",
"revealProblems": "onProblem"
}
},
{
"label": "start",
"type": "shell",
"command": "bash ${workspaceFolder}/.debug/start.bash",
"isBackground": true,
"dependsOrder": "sequence",
"dependsOn": [
"build"
],
"problemMatcher": [
{
"pattern": [
{
"regexp": "\\b\\B",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^.*START*",
"endsPattern": "^.*ERROR*"
}
}
],
"presentation": {
"reveal": "always",
"revealProblems": "onProblem"
}
},
{
"label": "stop",
"type": "shell",
"command": "bash ${workspaceFolder}/.debug/stop.bash",
"isBackground": true,
"problemMatcher": [
{
"pattern": [
{
"regexp": "\\b\\B",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^.*STOP*",
"endsPattern": "^.*ERROR*"
}
}
],
"presentation": {
"reveal": "silent",
"revealProblems": "onProblem"
}
}
]
}
build.bash
#!/bin/bash
BUG_MOCK_BUILD=1
sleep 10
if [ "$BUG_MOCK_BUILD" -eq 1 ]; then
echo " > -------------------
BUILD
ERROR
< ------------------- "
sleep 5
exit 1
else
echo " > -------------------
BUILD
SUCCESS
< ------------------- "
sleep 5
exit 0
fi
start.bash
#!/bin/bash
BUG_MOCK_STAR=1
sleep 10
if [ "$BUG_MOCK_STAR" -eq 1 ]; then
echo " > -------------------
START
ERROR
< ------------------- "
sleep 5
exit 1
else
echo " > -------------------
START
SUCCESS
< ------------------- "
sleep 5
exit 0
fi
stop.bash
#!/bin/bash
BUG_MOCK_STOP=1
sleep 10
if [ "$BUG_MOCK_STOP" -eq 1 ]; then
echo " > -------------------
STOP
ERROR
< ------------------- "
sleep 5
exit 1
else
echo " > -------------------
STOP
SUCCESS
< ------------------- "
sleep 5
exit 0
fi
QUESTIONS:
I - If the "build" fails, why does the IDE proceed to "start" (see image)?
II - Is it possible to use "problemMatcher" in reverse? In other words, proceed to the next task only if the previous one was successful?
Thanks!