Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve problemMatchers for tasks executed by vscode.tasks.executeTask api call #9207

Closed
wants to merge 1 commit into from

Conversation

vnfedotov
Copy link
Contributor

@vnfedotov vnfedotov commented Mar 16, 2021

What it does

Fixes #9205

Tasks executed with the direct call to runTask method (as it is in vscode.tasks.executeTask implementation) have no RunOptions, which also means they lose any ProblemMatchers that might be associated with this task.

Here we recreate RunOptions, resolving ProblemMatchers if they exist in TaskConfiguration.

How to test

  1. Test on a vscode plugin with a task contribution and problem matchers specified
  2. Task should produce output matching with problemMatcher regexp
  3. Run task with an vscode.tasks.executeTask call
  4. Task should complete, "Problems" view should show 1 new record

Review checklist

Signed-off-by: Vladimir Fedotov vfl@ispras.ru

@vince-fugnitto vince-fugnitto added tasks issues related to the task system vscode issues related to VSCode compatibility labels Mar 16, 2021
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vnfedotov thank you for your first contribution! Do you mind squashing your commits and we will proceed with a review 👍

cc @alvsan09 would you like to review?

…k api call

Signed-off-by: Vladimir Fedotov <vfl@ispras.ru>
@alvsan09
Copy link
Contributor

cc @alvsan09 would you like to review?

Sure @vince-fugnitto, I will review it as well !!

@alvsan09
Copy link
Contributor

HI @vnfedotov,
Can you share your test plugins?

@vnfedotov
Copy link
Contributor Author

Sure, @alvsan09
https://github.com/vnfedotov/problemMatcher-test-repo

Observed behaviour before change:

  1. Open "Test View"
  2. Click on a "test" item
  3. Task terminal opens, produces output specified in task.sh
  4. Task finishes succesfully
  5. "Problems" view is empty
  6. Select Terminal -> Run Task... menu
  7. Select "test" task
  8. Task runs in the same terminal, produces same output
  9. Task finishes succesfully
  10. "Problems" view has 1 new entry

Observed behaviour after this change:

  1. Open "Test View"
  2. Click on a "test" item
  3. Task terminal opens, produces output specified in task.sh
  4. Task finishes succesfully
  5. "Problems" view has 1 new entry
  6. Select Terminal -> Run Task... menu
  7. Select "test" task
  8. Task runs in the same terminal, produces same output
  9. Task finishes succesfully
  10. "Problems" view has 1 new entry

Copy link
Contributor

@RomanNikitenko RomanNikitenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello!
Thank you for your contribution!

I think the current approach works well except the use case when a user has configured a task and applied another problem matcher.

For example, for a typescript task tsc problem matcher is used. But a user can configure the task and set another problem matcher or an empty array for the problemMatcher field (like, Never scan the task output ). At running the configuration that value from tasks.json config file is used.

For your use case it's possible to configure the test task and override the problemMatcher filed in the tasks.json config file, but looking on the provided changes I think that task system will always use original problemMatcher from the task configuration.

Is it expected behavior?
Could you test the use case on VS Code side:

  • configure your test task and set another value for the problemMatcherfield or an empty array
  • run test task from the Test view
  • detect somehow which problemMatcher is used - the new value or the original value provided by your plugin.

Thank you!

@vnfedotov
Copy link
Contributor Author

@RomanNikitenko I believe it's done already as it is. The reason is: configured tasks (defined in tasks.json) use different TaskService entrypoint, they're started with TaskService.run which then proceeds to construct TaskCustomization object and pass it as RunOptions to TaskService.runTask. Actually, it's the reason for the behavior described as "before change": problemMatchers were working when started from the menu, and were not when started from the vscode api call. A call to vscode.tasks.executeTask runs TaskService.runTask directly, without looking into tasks.json, as it should, but also loses any information on problemMatchers, as it definitely should not.

I've updated https://github.com/vnfedotov/problemMatcher-test-repo to illustrate my point. I've added second problem matcher "typescript" and another line into test script that should match typescript regexp. Now it behaves as follows:

  1. Open "Test View"
  2. Click on a "test" item
  3. Task terminal opens, produces output specified in task.sh
  4. Task finishes succesfully
  5. "Problems" view has 1 new entry, matching line for the "my-task" problem matcher
  6. Select Terminal -> Run Task... menu
  7. Click on a cogwheel for a "test" task
  8. tasks.json is created, with the current configuration of a "test" task extracted from cache.
  9. Change problem matcher value to "$typescript"
  10. Select Terminal -> Run Task... menu
  11. Select "test" task
  12. Task runs in the same terminal, produces same output
  13. Task finishes succesfully
  14. "Problems" view has 1 new entry, matching line for the "typescript" problem matcher
Kapture.2021-03-18.at.16.43.13.mp4

@RomanNikitenko RomanNikitenko self-requested a review March 22, 2021 15:37
Copy link
Contributor

@RomanNikitenko RomanNikitenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vnfedotov
you are right!

I tested both cases according to #9207 (comment)

and it works as expected for me!

I detected a bug: there are 2 items with the label test after configuring your task
tasks_bug_configure

But I believe it's not related to your changes - something wrong with Configure Task action.

@RomanNikitenko
Copy link
Contributor

@vince-fugnitto
could you review the PR again when you have a chance

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vnfedotov I noticed there are errors when attempting to run the test task:

task ERROR Error resolving task 'test': TypeError: Cannot read property 'group' of undefined

test-error.mp4

This however does not seem to be an issue with the pull-request but rather #9189. I confirmed it works before that commit.

@kostmetallist
Copy link
Contributor

Hey guys, are there any critical blockers preventing to merge? I've updated the changed function to get rid of the conflicts, so it's no longer affected by previously introduced parallel tasks locking feature. Could you please take a look at #10166?

@RomanNikitenko
Copy link
Contributor

The changes were merged within #10166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tasks issues related to the task system vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tasks started from vscode.tasks.executeTask have no problemMatchers
5 participants