mrcrowl / vscode-hg

Integrated Mercurial source control for Visual Studio Code
MIT License
71 stars 37 forks source link

Part of #95: Create infrastructure for testing #120

Closed hdpoliveira closed 4 years ago

hdpoliveira commented 4 years ago

@incidentist I decided to take a shot at the testing. I was able to make the helloworld test work!! 😃

This creates a dummy test, along with all the infra for running it. The test doesn't even call the extension, and should be deleted once we populate the tests dir.

It can be run from vscode, by going in the debug tab (ctrl+shift+D) and selecting "Run Extension Tests". It can be run from command line, given no vscode instance is running, by running "npm test".

hdpoliveira commented 4 years ago

@incidentist please let me know if you want me to merge this or you want to merge it into https://github.com/mrcrowl/vscode-hg/pull/106

hdpoliveira commented 4 years ago

I don't think we want to pass a workspace to the sandbox vscode. The first test will work fine, but the test running after that will have an unknown environment that needs to be cleared.

I checked SVN extension and they use the same approach as the one in this PR. Each test will create its own temp dir and use that to do the testing. (reference https://github.com/JohnstonCode/svn-scm/blob/master/src/test/commands.test.ts)

One thing they do is disable extensions, so that is indeed missing here.

I got your status test to work on this infra. I'll push it here now :smiley:

incidentist commented 4 years ago

Great! What stumped me is: the test runs after the sandbox VSCode is launched. If the test creates its own temp dir, how do I tell the sandbox vscode to set the workspace to that temp dir, after the workspace is already open? You're right that the svn extension does this, I just don't see where the open workspace gets associated with the repo that is created by the tests. I guess I'll find out :).

incidentist commented 4 years ago

This looks like exactly what we need. I will test it tonight.

hdpoliveira commented 4 years ago

NICE! Now I guess we need to populate the tests database, and a good place to start are the PowerShell scenarios created by @mrcrowl in the test directory. We should also make sure we add tests for new features. I'll try to write one for the purge extension tomorrow.