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

tests/plugins: refactor #235

Merged
merged 1 commit into from
Mar 22, 2023
Merged

Conversation

GaetanLepage
Copy link
Member

In the existing version of the tests, all the files from the tests/plugins/ folder are listed and imported.
This was preventing us from structuring the content of this directory.
I removed this in favor of hard-coded imports (i.e. we explicitly list the test files we wish to import).
This allows for a conventional way of ordering the test cases.

I suggest that we keep the structure of the tests/plugins/ folder exactly the same as the one of the plugins/ folder.

@GaetanLepage GaetanLepage requested review from traxys and pta2002 March 10, 2023 09:26
@traxys
Copy link
Member

traxys commented Mar 10, 2023

There is another option, we can have default.nix files for each subdirectories that would perform exactly the same work as the root file, i.e: Concat all the subfiles in a list with the path added to the name.

I don't have any problems with the approach in this PR, but I don't know what you think @pta2002

@pta2002
Copy link
Collaborator

pta2002 commented Mar 10, 2023

You can have the automatic listing of the files and still support nesting. Just takes a bit more work, but not too much. I'd personally be more in favor of this since it avoids having to change the tests file every time

@GaetanLepage
Copy link
Member Author

You can have the automatic listing of the files and still support nesting. Just takes a bit more work, but not too much. I'd personally be more in favor of this since it avoids having to change the tests file every time

Hmm I agree that it is feasible. I actually have already taken a look at this before submitting this PR.
I feel like the explicit listing is more simple-stupid but is still satisfying. If a PR adds a test, we just have to include it in the main file.
For me it is exactly the same process as when we add a new plugin: We have to add the file of the plugin and mention it in the plugins/default.nix file as well.

Anyway, if you feel like it is indeed better to support automatic nesting of nested folders, I can understand :)

@pta2002
Copy link
Collaborator

pta2002 commented Mar 13, 2023

I think specifically in this case it's better than in the case of plugins. Picture this:

  • You add a new test, by creating the file
  • You submit a PR for it

Now, imagine that you had to manually list it. What would the results be? The test just straight up would not run, because it's easy to forget to add to it, and it's really easy to miss without creating some automated rule for it... and at that point you might as well just auto-import it ;)

This isn't as much of an issue with plugins because ideally you'd be testing it anyway and you'd catch it if you forgot to import it.

@GaetanLepage
Copy link
Member Author

I think specifically in this case it's better than in the case of plugins. Picture this:

* You add a new test, by creating the file

* You submit a PR for it

Now, imagine that you had to manually list it. What would the results be? The test just straight up would not run, because it's easy to forget to add to it, and it's really easy to miss without creating some automated rule for it... and at that point you might as well just auto-import it ;)

This isn't as much of an issue with plugins because ideally you'd be testing it anyway and you'd catch it if you forgot to import it.

I agree. It makes sense indeed !
I will take a look at that soon :)

@GaetanLepage
Copy link
Member Author

GaetanLepage commented Mar 17, 2023

Hi @pta2002 !

@traxys and I have been working to make this new proposal.
We now have a much clearer test cases management.

Changes:

  1. Everything regarding testing is now in the tests/ directory. In particular, the code that was previously in lib/check.nix has been moved there.
  2. The folder tests/test-sources/ contains all and only the source of the test cases.
  3. The nix files at the root of the tests/ directory contain the necessary functions to gather the test cases and convert them to derivations. Btw, the gathering is automatically looking for all the test cases recursively in tests/test-sources/
  4. The previous tests/flake.nix has been deleted. The test cases that were living in it were moved to the tests/test-sources/ directory.

We are looking forward to your review,

Best :)

@GaetanLepage GaetanLepage force-pushed the tests branch 4 times, most recently from 5127636 to 66a313c Compare March 18, 2023 23:38
Copy link
Collaborator

@pta2002 pta2002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good, thanks for the work in this, and sorry for taking so long to look at it!

@GaetanLepage
Copy link
Member Author

This looks very good, thanks for the work in this, and sorry for taking so long to look at it!

Thanks for the feedback :)

@GaetanLepage GaetanLepage merged commit db5061b into nix-community:main Mar 22, 2023
@GaetanLepage GaetanLepage deleted the tests branch March 22, 2023 06:44
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.

3 participants