tfausak / purple-yolk

:hatching_chick: A Haskell IDE for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=taylorfausak.purple-yolk
MIT License
26 stars 2 forks source link

Add integration tests #88

Open EduardSergeev opened 1 week ago

EduardSergeev commented 1 week ago

Not sure if you need it but I thought it might be helpful to have some tests to check basic functionality of Purple York and to run them via matrix build to check for regression.

This change contains three simple tests defined in providers.test.ts. Each test:

E.g. a test which is defined as:

  test('Error only', () => {
    return runFileTest('Error.hs', [DiagnosticSeverity.Error, 1], async (_, diags) => {
      assert.lengthOf(diags, 1);
      assert.include(diags[0]?.message, 'Not in scope: type constructor or class');
    });
  });

loads Error.hs, waits until the extension produces 1 error and then runs the code with those two assertions.

Test suite can be run via

npm test

or with test coverage report (produces by c8):

npm run coverage

Current code coverage:

=============================== Coverage summary ===============================
Statements   : 64.83% ( 780/1203 )
Branches     : 51.96% ( 53/102 )
Functions    : 62.85% ( 22/35 )
Lines        : 64.83% ( 780/1203 )
================================================================================

And one from CI

This change also adds matrix build which runs all tests on all supported platforms with various GHC versions. Here is an example of new CI run. It also uploads test coverage to https://coveralls.io, e.g. recent coverage report.

tfausak commented 1 week ago

Thanks! This is a definite improvement. It would be nice to have some tests to make sure that basic functionality works, at least. However this is also a lot of extra stuff that I'm not familiar with and might not want to maintain. I'll think about it.