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

Fix tests and implement testing in CI #30

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Hi-Angel
Copy link
Contributor

@Hi-Angel Hi-Angel commented Dec 10, 2024

The project have had some tests, which even though were apparently from Haskell time, they still seem to be testing some code. The imports sorting probably requires some syntax changes (e.g. to stop accounting for qualified keyword), but the algo is simple and somebody may still be using it.

Now, the interesting part is that the project has check Makefile rule (one that I'm removing here). I have no slightest idea what it was written for. As described in the commit, it did the following 4 things:

  1. For every .el file it was searching its tests.el counterpart. Which doesn't exist.
  2. It was checking the correctness of declare-functions. Which would be fine, wasn't it for the fact the project has zero declare-functions.
  3. It was checking that ert exists, which it does on all supported Emacs versions.
  4. It was removing .elc files before running the tests. Why? 🤷‍♂

Replacing check with much simpler test rule which just runs tests, besides being actually useful, also improves running time as follows:

Initial state Before After
Non-compiled 2.177 1.614
Compiled 2.182 0.340

Fixes:

    tests/purescript-sort-imports-tests.el:31:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
    tests/purescript-sort-imports-tests.el:41:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
    tests/purescript-sort-imports-tests.el:51:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
    tests/purescript-sort-imports-tests.el:61:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
    tests/purescript-sort-imports-tests.el:73:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
    tests/purescript-sort-imports-tests.el:86:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
    tests/purescript-sort-imports-tests.el:99:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
    tests/purescript-sort-imports-tests.el:118:14: Warning: ‘goto-line’ is for interactive use only; use ‘forward-line’ instead.
Fixes:

    tests/purescript-str-tests.el:1:1: Error: file has no ‘lexical-binding’ directive on its first line
The code that's being removed here made no sense. It is a `check`
rule, and it did the following things:

1. For every `.el` file it was searching its `tests.el` counterpart.
    Which doesn't exist.

2. It was checking the correctness of `declare-function`s. Which would
    be fine, wasn't it for the fact the project has zero
    `declare-function`s.
3. It was checking that `ert` exists, which it does on all supported
    Emacs versions.
4. It was removing .elc files before running the tests. Why? 🤷‍♂️

Replace everything with a single `test` rule which simply loads the
test files and runs the tests.

Besides being actually useful, this also improves running time as:

    Initial state | Before | After |
    Non-compiled  | 2.177  | 1.614 |
    Compiled      | 2.182  | 0.340 |
@Hi-Angel
Copy link
Contributor Author

New commit:

Compile .el files at O(1) instead of O(n)

The older code was running Emacs separately for each .el file. Change
the code so that all .el files are passed at once.

This improves build time by x5:

* before: 1.272 sec
* after:  0.257 sec

The older code was running Emacs separately for each .el file. Change
the code so that all .el files are passed at once.

This improves build time by x5:

* before: 1.272 sec
* after:  0.257 sec

Also simplify the rule declaration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant