-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Enhancement: Supporting deep comparison of tasks with reference value in custom properties #9647
Enhancement: Supporting deep comparison of tasks with reference value in custom properties #9647
Conversation
These cases includes the conditions when tasks with reference value as custom properties. In tests with @thiea/task, 33 passing and 2 failing is expected. Signed-off-by: Victor Li <[email protected]>
…operties deeply. All the unit-test cases for @thiea/task is expected to pass. (35 passing, 0 failing) Signed-off-by: Victor Li <[email protected]>
@@ -15,6 +15,7 @@ | |||
********************************************************************************/ | |||
|
|||
import { expect } from 'chai'; | |||
import { foobarTaskFixture } from '../node/test/test-helper'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@magician-margatroid browser
(frontend) should not import anything from node
(backend), even if it is simply for test purposes: code organization. Given that the foobarTaskFixture
is simply for test purposes, you can include the contents directly in the task-definition-registry.spec.ts
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @vince-fugnitto . Excuse me and I'll improve it.
* Moving foobarTaskFixture into task-definition-registry.spec.ts. Signed-off-by: Victor Li <[email protected]>
Hi @vince-fugnitto , when you have the time, could you pls help to have a look at the build check result? As it indicates, it seems the Build / ubuntu-18.04, Node.js v12.x (pull_request) failed after 14m — ubuntu-18.04, Node.js v12.x. I found Personally I think this new commit doesn't have side effects, and also executed unit-tests locally with all-green. |
Thanks. This time all that succeeded. |
reveal: RevealKind.Always, | ||
showReuseMessage: true, | ||
}; | ||
const foobarTaskFixture = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: what does a fixture
represent, it is the first time I heard of this terminology for tasks
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice point. Well, frankly I didn't aim to use it exclusively for tasks
, but I mean to use "test fixtures" here. In my understanding fixture
can be something stable across runs of tasks. E.g., a file loaded with sample data or a script setting up stable env for task.
Perhaps here I need to change it into mock or fake.
foobarTaskFixture.conf('id_1', 'type_1'), | ||
foobarTaskFixture.conf('id_2', 'type_2'), | ||
); | ||
expect(res).to.be.not.ok; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: rather than okayness
, we can simply do truthy checks.
expect(res).to.be.true;
or
expect(res).equal(true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. I'll change it in this way.
}); | ||
|
||
it('should return true if given 2 same task configurations with empty arrays (different by reference) as custom property', () => { | ||
const res = registry.compareTasks( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the use of res
a lot in the tests, what does it represnt? Perhaps a clearer name should be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion. I agree and I meant "result" here. I'll change them.
* Change okayness into truthy checks. Signed-off-by: Victor Li <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested this change and it works as expected 👍
The code looks good to me as well!
Thanks @magician-margatroid !
Ah, good to know it, @alvsan09 thx for your testing. It's my pleasure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes work well for me, I verified with the described steps in #9646 👍
Thank you for the contribution, and looking forward to many more in the future!
I found what's the problem... cust_tasks_config.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested according to the steps to reproduce
section of the issue, it works well for me.
I think it makes sense to squash the changes in 1 or 2 commits before merging.
I used the new |
Hi everyone, thanks a lot for all your work. It's my pleasure and appreciate your help and analysis all the way. |
… in custom properties (eclipse-theia#9647) The commit adds deep comparison of tasks, including tests: - use `JSONExt.deepEqual` from `@phosphor/coreutils` to compare custom properties deeply. - add unit-test cases for `compareTasks` in `task-definition-registry.ts`: these cases includes the conditions when tasks with reference value as custom properties. Signed-off-by: Victor Li <[email protected]>
What it does
Fixes: #9646
Issue link: in short, tasks with same content but different reference value as custom properties are treated as different tasks, e.g.,
[]
,{prop: 'value'}
. This can lead to duplicate execution of same task.This PR includes 2 commits:
task-definition-registry.ts
to ensure the logic of distinguishing.compareTasks
method.How to test
Unit test:
@theia/task
will ends up with 33 passing and 2 failing.@theia/task
will ends up with 35 passing and 0 failing.Manually integration test:
Review checklist
Reminder for reviewers