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

Ert indent testing #63

Merged
merged 4 commits into from Jan 3, 2019

Conversation

Projects
None yet
3 participants
@etu
Copy link
Collaborator

etu commented Jan 3, 2019

So I've done some work on writing ert tests for indentation in nix-mode using nix-indent-line as indentation function.

Ignore the first commit 98426b9 since it's part of the PR #61 which kinda makes the indentation a lot better (imo).

But this PR depends on that change for this test to pass so I based this branch on those changes.

Tests run as easily as:

nix-shell --pure --run "make test" -p gnumake emacs

And to see that the test works for the test case I've added, just open the file list-contents.nix and mess something up in there (like de-indent something that should be indented) and run the test again. Then the indentation mode will fix the mess and compare it to the file -- which will fail.

And, more tests are needed. Much more tests. For different cases. I will grab a few of the ones from #60 because they are quite small and good.

This work is heavily inspired by how php-mode does it's indentation testing, but quite much simpler since php has different indentation standards which we kinda can ignore here.

cc @grahamc @matthewbauer

etu added some commits Jan 2, 2019

Add function to indent things in blocks for nix-indent-line
Add a function `nix-indent-first-line-in-block` that checks if the
last word on the previous line is one of "let, import, [, =, (, {".
Then it adds two spaces of indent to the one of the previous line.

And if you stand on the first line of a file, it defaults to indenting
the line to zero spaces.

@etu etu force-pushed the etu:ert-indent-testing branch 2 times, most recently from cdc5b8b to b95ab8f Jan 3, 2019

@etu etu force-pushed the etu:ert-indent-testing branch from b95ab8f to 02b59d9 Jan 3, 2019

@matthewbauer

This comment has been minimized.

Copy link
Member

matthewbauer commented Jan 3, 2019

Thanks a lot! I want to get travis working but don't have permissions to add it on this repo.

@matthewbauer matthewbauer merged commit 6445ebf into NixOS:master Jan 3, 2019

@etu etu deleted the etu:ert-indent-testing branch Jan 3, 2019

@etu

This comment has been minimized.

Copy link
Collaborator Author

etu commented Jan 3, 2019

@matthewbauer That would be great to have, do you know who to talk to to set that up?

@grahamc

This comment has been minimized.

Copy link
Member

grahamc commented Jan 3, 2019

@grahamc

This comment has been minimized.

Copy link
Member

grahamc commented Jan 4, 2019

Travis is set up now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment