Skip to content

tests: use an easy to include setup file #541

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

Closed
wants to merge 2 commits into from
Closed

Conversation

rfourquet
Copy link
Contributor

When wanting to run a specific test/testset, it's easy to copy-pase it
into the REPL, but it can be annoying to find the setup-code, like
constants or functions defined usually at the top of the test file.
All this setup code is here put in test/setup.jl, so that it's always
predictable (and easy) what one has to do to inject to required
dependencies in the REPL: include("test/setup.jl").

Another nice thing to have is to be able to run one single test file. But it's currently not always supported (e.g. include("test/generic/Matrix-test.jl") won't work). So I also propose to conditionally include the "setup.jl" file at the top of test files (which need setup), so that they can be run independently. I currently did it only for "Matrix-test.jl" and will continue if the idea is supported. This looks like

if !@isdefined SETUP
   include("../setup.jl")
end

When wanting to run a specific test/testset, it's easy to copy-pase it
into the REPL, but it can be annoying to find the setup-code, like
constants or functions defined usually at the top of the test file.
All this setup code is here put in test/setup.jl, so that it's always
predictable (and easy) what one has to do to inject to required
dependencies in the REPL: `include("test/setup.jl")`.
@rfourquet rfourquet added the test This change adds or pertains to unit tests label Nov 27, 2019
@fieker
Copy link
Contributor

fieker commented Nov 27, 2019 via email

@rfourquet
Copy link
Contributor Author

Yes, I had a similar idea for a future PR, mimicking what is available in Julia: Base.runtests(list_of_test_names).

@fieker
Copy link
Contributor

fieker commented Nov 27, 2019 via email

@rfourquet
Copy link
Contributor Author

Difference being that "our" version can run selected tests in the same julia or not.

I noticed yes. I can see the usefulness of "in the same julia" when hacking a routine at the REPL and having the tests take the changes into account immediately, do you have another use case?

@fieker
Copy link
Contributor

fieker commented Nov 27, 2019 via email

@thofma
Copy link
Member

thofma commented Nov 27, 2019

Addtionally, it is faster since you don't have to compile everything over and over again.

@rfourquet
Copy link
Contributor Author

Makes sense, thanks.

@rfourquet
Copy link
Contributor Author

The problem this was trying to address is mostly solved for me with ReTest. The rare cases where I'd still like to have a setup.jl file is not enough motivation, so I will close but I can update the PR if someone has an interest.

@rfourquet rfourquet closed this Feb 11, 2021
@rfourquet rfourquet deleted the rf/test/setup branch February 11, 2021 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test This change adds or pertains to unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants