Skip to content

Test problem matcher file location auto detection. #74824

Closed

Description

@alexr00

Complexity: 2

Ref: #449

Open or create a folder and create a new folder Folder within it. In the new folder, create a test file.txt with a few lines of text.

Create a script file at the root of your open folder similar to this:

Windows (script.bat):

echo Problem at: \Folder\file.txt firstProblem:1
echo Problem at: C:\Users\alros\Documents\OpenFolder\Folder\file.txt secondProblem:1

Linux, macOS (script.sh, make it executable):

#!/bin/sh
echo Problem at: /folder/file.txt firstProblem:1
echo Problem at: /Users/joao/Work/fakeproject/folder/file.txt secondProblem:1

Create a task:

        {
            "label": "Make Problems",
            "type": "shell",
            "command": ".\\problems.bat",
            "problemMatcher": {
                "pattern": {
                    "regexp": "^Problem at: (.*) (.*):(\\d)$",
                    "file": 1,
                    "message": 2,
                    "location": 3
                },
                "fileLocation": "autoDetect"
            }
        }

Run the task and verify that two problems are created. Those two problems should both open the correct file when clicked on.
Try changing the "fileLocation" in the task to "absolute" and "relative" verify that only the expected problem correctly opens the file when clicked on.
Try removing the "location" from the problem matcher and instead having "kind": "file" and confirm that it still works and the expected files are clickable.
Try moving your Folder to another directory outside of the folder you have open. Change the "fileLocation" to ["autoDetect", <parent folder of Folder>]. Verify that the the problems are still clickable and go to the right file.

Note: You will accumulate a lot of problems doing this and they will not go away without a reload. This is expected since problems only clear if the exact same task is run and generates no problems.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions