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

Support preLaunchTask and postDebugTask #6247

Merged
merged 1 commit into from
Oct 11, 2019
Merged

Support preLaunchTask and postDebugTask #6247

merged 1 commit into from
Oct 11, 2019

Conversation

tolusha
Copy link
Contributor

@tolusha tolusha commented Sep 23, 2019

Signed-off-by: Anatoliy Bazko abazko@redhat.com

What it does

It adds support for preLaunchTask and postDebugTask
https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes

  • If task is configured the label of the task is used to identify and to display.

Reference issue

#3409

How to test

  1. Add any debug configuration
  2. Add preLaunchTask and postDebugTask
            "preLaunchTask": "taskStart",
            "postDebugTask": "taskEnd"
  1. Configure tasks, for instance:
{
    "tasks": [
        {
            "type": "shell",
            "label": "taskStart",
            "command": "sleep 1s && echo Start"

        },
        {
            "type": "shell",
            "label": "taskEnd",
            "command": "sleep 1s && echo End"
        }
    ]
}

Review checklist

Reminder for reviewers

@tolusha tolusha added tasks issues related to the task system vscode issues related to VSCode compatibility debug issues that related to debug functionality labels Sep 23, 2019
@tolusha tolusha self-assigned this Sep 23, 2019
@akosyakov
Copy link
Member

@tolusha ready for review?

@tolusha
Copy link
Contributor Author

tolusha commented Sep 24, 2019

@akosyakov
Thank you for review.
The PR isn't completed yet. I have to handle one more case when preLaunchTask failed I shouldn't start a debug session. The problem is that there isn't easy way to check an exit code of the task.
I am considering adding a dedicated method into TaskServer [1] but in this case I shouldn't remove tasks from the TaskManager [2] immediately but keep them for a while.
WDYT?

[1] https://github.com/theia-ide/theia/blob/ab/debugtasks/packages/task/src/node/task-server.ts#L35
[2] https://github.com/eclipse-theia/theia/blob/ab/debugtasks/packages/task/src/node/task-server.ts#L90

@tolusha
Copy link
Contributor Author

tolusha commented Sep 24, 2019

/cc @RomanNikitenko

@akosyakov
Copy link
Member

cc @eclipse-theia/task-extension please see #6247 (comment)

@RomanNikitenko
Copy link
Contributor

@tolusha
What about adding deferred exit code to runtime info . Will it help you for your goals?

@akosyakov
does that make sense?

@tolusha
Copy link
Contributor Author

tolusha commented Sep 24, 2019

I am about to submit changes

@tolusha
Copy link
Contributor Author

tolusha commented Sep 24, 2019

@akosyakov @RomanNikitenko
I've updated PR. Have a look at proposed changes regarding task.
If they look good in general I will continue fixing remarks.

@akosyakov
Copy link
Member

@tolusha please rely on review from @elaihau and @RomanNikitenko for the task extension

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.

I think we should avoid using timeout for deletion of tasks.
Otherwise it leads to the bug: after completion of a task, the task is considered as running during timeout. You can check it using Terminal => Show Running Tasks.

@tolusha tolusha force-pushed the ab/debugtasks branch 2 times, most recently from 080150e to a4345ae Compare October 3, 2019 08:56
@tolusha
Copy link
Contributor Author

tolusha commented Oct 3, 2019

@elaihau @RomanNikitenko
It is ready to review again

@elaihau
Copy link
Contributor

elaihau commented Oct 4, 2019

@elaihau @RomanNikitenko
It is ready to review again

@tolusha
i don't think this comment is resolved. if you don't think it is within the scope of your pull request please create a github issue. Thank you !

@tolusha
Copy link
Contributor Author

tolusha commented Oct 7, 2019

@elaihau
I don't use runBylabel anymore.
Instead of that I invoke runTaskInWorkspace [1] which scans all task [2] related to current root and run a needed one.

[1] https://github.com/eclipse-theia/theia/blob/ab/debugtasks/packages/debug/src/browser/debug-session-manager.ts#L410
[2] https://github.com/eclipse-theia/theia/blob/ab/debugtasks/packages/task/src/browser/task-service.ts#L432

@ShimonBenYair
Copy link
Contributor

@tolusha
thanks a lot for this improvement , i also need it.
Do you have any estimation when you will merge your PR ?

@tolusha
Copy link
Contributor Author

tolusha commented Oct 7, 2019

@ShimonBenYair
I will merge it once it get approved by @elaihau and @RomanNikitenko
It would be nice if you try it also and check if it works as expected.

Copy link
Contributor

@elaihau elaihau left a comment

Choose a reason for hiding this comment

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

I tested the following scenarios in my local env:

  • single root workspace, configured task
  • multi root workspace, configured task
  • single root workspace, detected task
  • multi root workspace, detected task

All worked except for one thing. Please see GIF below (kingly ignore the error message - it was caused by my settings):

Peek 2019-10-07 23-03

As shown, the task "npm: lintAAA" was successfully started, however the problem matcher was not resolved and therefore the warning in task output was not parsed, and no markers were created in the problems view.

When I ran the task "npm: lintAAA" alone I was getting:

Peek 2019-10-07 23-04

Also, I didn't see the prompt that asked users for problem matcher definitions, if the task was started from the launch config:

Peek 2019-10-07 23-08

@elaihau
Copy link
Contributor

elaihau commented Oct 8, 2019

I revisited task-service.ts and thought the problems (that I found above) were likely caused by my earlier bad design decisions :)
Please feel free to file separate follow-up issues in github. They don't have to be resolved in this pull request.
@tolusha

@tolusha
Copy link
Contributor Author

tolusha commented Oct 8, 2019

@elaihau Thank you for review. It was very helpful
I will provide update soon.

@tolusha tolusha marked this pull request as ready for review October 9, 2019 11:11
@tolusha
Copy link
Contributor Author

tolusha commented Oct 9, 2019

@elaihau
PR is updated to use problem matchers

@tolusha
Copy link
Contributor Author

tolusha commented Oct 10, 2019

@elaihau Here is some clarification

As shown, the task "npm: lintAAA" was successfully started, however the problem matcher was not resolved and therefore the warning in task output was not parsed, and no markers were created in the problems view.

Fixed: If problem matcher is configured then it will be used.

Also, I didn't see the prompt that asked users for problem matcher definitions, if the task was started from the launch config:

Won't fix: If problem matcher isn't configured and task is run from a launch config then menu to select problem matcher won't be shown. Like in VS Code.

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.

I tested the following:

  • running custom configured task
  • running detected tsc task
  • running configured tsc task
  • running debug configuration with preLaunchTask: the task is started, prompt that asked users for problem matcher definitions is not displayed. I checked - VS Code behavior is the same.

The PR changes approach of displaying labels for TaskRunQuickOpenItem and TaskConfigureQuickOpenItems for configured tasks - I checked - VS Code behavior is the same

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

changes to the debug and plugin extensions look good to me

not sure when @elaihau has a chance to have a look, from comments above it looks like happy too now

Copy link
Contributor

@elaihau elaihau left a comment

Choose a reason for hiding this comment

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

I tested one more time and confirm the problems it used to have are fixed. Thank you for your work !

@tolusha
Copy link
Contributor Author

tolusha commented Oct 11, 2019

I am going to squash commits and merge.

Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
@ShimonBenYair
Copy link
Contributor

@tolusha

Hi, will this change be released on version 12 of Theia ?

@marcdumais-work
Copy link
Contributor

Hi, will this change be released on version 12 of Theia ?

Yes, this change will be part of Theia release 0.12.0, tentatively scheduled for October 31st.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug issues that related to debug functionality 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.

6 participants