question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test timeout for settings causes unit testing to slow down unnecessary (most of the time).

See original GitHub issue

Currently we have a workaround regarding settings changes during ourunit tests. See here:

https://github.com/Microsoft/vscode-python/blob/065b377a5a178f05005d62c6ce964e9ffb5105f5/src/test/common.ts#L38

This was put in to guard against upstream VSCode changes that would make settings updates non-immediate. However, while that problem has happened (and no doubt caused a lot of consternation while attempting to debug) it doesn’t mean we should pay a 2-second delay tax every time we run the tests (and what happens if the delay is > 2sec? We are no better off…).

As an alternate solution, could we simply do a spin-loop using the get command to ensure we are seeing the change?

Something like:

const expected: string = some_expected_value;
let actual: string = settings.get(key);
let counter: number = MAX_GET_TRIES; // or something like that
while (expected !== actual) {
    counter -= 1;
    if (counter < 0) {
        throw Error_Getting_Value_Exception;
    }
    await sleep(GET_SETTING_SLEEP_VAL);
    actual = settings.get(key);
}

…this way we can be alerted to a problem in VSCode as has happened in the past, but we don’t incur a 2-second delay tax for each call?

Or even more simply:

settings.update(setting, value, configTarget);
if (settings.get(setting.key) !== setting.value) {
    throw Update_Settings_Not_Immediate_Exception;
}

This way we can notify the VSCode team when we find a regression in this functionality, and either skip tests that rely on it, or enable a wait period only until the regression is corrected upstream.

cc: @brettcannon @ericsnowcurrently @DonJayamanne

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Aug 9, 2018

My suggestion is simple (comment the code out)

. I would also propose that we leave the await sleep(2000); in a comment with a description of why it is there as well.

https://github.com/Microsoft/vscode-python/issues/2356#issuecomment-411614663

0reactions
DonJayamannecommented, Jan 10, 2019

No longer required

Read more comments on GitHub >

github_iconTop Results From Across the Web

9 Ways To Make Slow Tests Faster - Semaphore CI
At Semaphore, we've seen our fair share of tests and have identified 9 ways to make your slow tests faster.
Read more >
Unit Testing Angular Service that uses $timeout with ...
I'm stumped on how to unit test this with Jasmine at the moment - How do I do this? If I use $timeout.flush()...
Read more >
7 Costly Mistakes That One Needs to Avoid in Angular Test ...
Protractor and Jasmine tests failing intermittently? Here we discuss some reasons for test timeouts and other common failures.
Read more >
9 Understanding timeouts - Testing Angular Applications
Timeout errors are the most common problem people encounter when using Protractor for the first time. Understanding what causes them and how to...
Read more >
Async waits in React Testing Library - Reflect.run
This asynchronous behavior can make unit tests and component tests a bit ... and allows async code to be read top-down rather than...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found