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

Add the ability to install test dependencies and run tests to Pkg #6191

Merged
merged 8 commits into from
Mar 21, 2014

Conversation

burrowsa
Copy link
Contributor

Pkg.test("PackageName") will install a package's test dependencies
(marked with @test in the REQUIRES file) then run its tests. If the
tests fail or there is no run_tests.jl provided then an error is raised.

`Pkg.test("PackageName")` will install a package's test dependencies
(marked with `@test` in the REQUIRES file) then run its tests. If the
tests fail or there is no run_tests.jl provided then an error is raised.
@mlubin
Copy link
Member

mlubin commented Mar 17, 2014

@IainNZ

@@ -72,7 +79,7 @@ function write(io::IO, reqs::Requires)
end
write(file::String, r::Union(Vector{Line},Requires)) = open(io->write(io,r), file, "w")

function parse(lines::Vector{Line})
function parse(lines::Vector{Line}, test::Bool=false)
Copy link
Member

Choose a reason for hiding this comment

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

I think this would do better as a keyword argument. It is not obvious what parse(lines, true) means, but parse(lines, test=true) makes it obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree and will change this

@ivarne
Copy link
Member

ivarne commented Mar 17, 2014

This also forces a convention on the name of the run_tests.jl file, which in my opinion is much better than the long list in https://github.com/IainNZ/PackageEvaluator.jl/blob/master/src/package.jl#L146-159. There is no reason to not make a standard.

@IainNZ
Copy link
Member

IainNZ commented Mar 17, 2014

I've been in the trenches with package testing for about 12 months, initially in favour of a "standard" like this, and I've learnt that making it a standard is indeed a pretty big point of contention. Even if this does go through, there will still be many packages that don't comply or don't want to comply so PackageEvaluator isn't going anywhere.

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

Having said that, I think the @test thing is great, and I'd still like there to be a standard - but its not clear that this is the right way to do it.

In fact, I think a declarative list of files to be run that could be run independently might be a better idea, rather than making a main script file. But again, we're getting to the infinite discussion we've already had on julia-dev and "Julep 2" (https://gist.github.com/IainNZ/6086173)

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

See also: https://github.com/johnmyleswhite/PackageTesting.jl for more ideas

@burrowsa
Copy link
Contributor Author

My motivator for this was wanting to be able to add test dependencies. Previously I just put my test dependencies in the travis config but that broke on http://status.julialang.org/ (and anywhere else the tests were run that wasn't travis) so I had to put my test dependencies in REQUIRES which seemed nasty. Most other package tools I've used in other languages allow you define test dependencies and link them to running the tests. I seem to recall that some (maven?) might even uninstall the test dependencies after the tests are run but that felt over the top.

It seems disappointing if there can't be a standard way to run tests for all Julia packages.

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

Yeah... maybe I'm just jaded. I kinda gave up, and just went with doing whatever it takes to make it work, I mean, check out the exceptions here:
https://github.com/IainNZ/PackageEvaluator.jl/blob/master/extra/genresults.jl#L115
and the logic in the link above.

I think people would be able to get behind the @test but the other part is tougher. Maybe we can do some sort of strawpoll on julia-dev for either a "run_tests.jl" style master file or declarative file format, and go with that.

@mlubin
Copy link
Member

mlubin commented Mar 18, 2014

What about splitting out the @test dependency part and leaving an API to access it, removing Pkg.test? This will raise less objections and should be easy to merge. We can move standardizing the testing script to another issue.

@Keno
Copy link
Member

Keno commented Mar 18, 2014

I'm wondering whether making the REQUIRE format more complicated is worth it for that purpose. Why not a seperate REQUIRES.test?

@mlubin
Copy link
Member

mlubin commented Mar 18, 2014

That's also reasonable. The testing dependencies don't need to be stored in METADATA.

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

If you have a declarative format for the testing files, you can include it in there as well, e.g. as json

{
"dependencies" : ["FactChecker"],
"tests" : [["test/runfirst.jl", "test/runsecond.jl"],
              "test/foo.jl",
              "test/bar.jl"]
}

where things have to be run in sequence if nested, otherwise any order

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

Theres also this: https://github.com/IainNZ/PackageEvaluator.jl/blob/master/extra/genresults.jl#L134-L138

    if pkg_name == "TimeSeries" || pkg_name == "MarketTechnicals"  # SUPER HACKY
        try
            Pkg.clone("git://github.com/JuliaQuant/MarketData.jl.git")
        end
    end

for non-registered dependencies that could be handled in a declaritive format, but doesn't fit in the proposed @test format (well, I guess it could, but might be confusing)

@burrowsa
Copy link
Contributor Author

I guess I could split out the test dependency stuff and forget the test running bit but I would expect these two things to go together. I could add an API to Pkg that installs the test deps and then make PackageTesting.jl or something similar call it, except PackageTesting.jl isn't in METADATA so I guess no one uses it.

When I was first introduced to Julia (by Stefan Karpinski's talk at codemesh 2013) one of the selling points was a package manager that was git based so that any user of a package was already in a position to hack on it and create pull requests. This can't be wholly true if the user can't easily run the tests on the package.

I know I'm new around here and I'm sorry for going over old ground. I don't care what the standard is but I do believe there should be a standard way of running tests. I also believe that test dependencies should be supported.

@milktrader
Copy link
Contributor

I like the way Gemfiles are configured where you could do something along the lines of this pseudocode in the REQUIRE:

DateTime

group :test do
FactCheck, version="0.3.0"
MarketData, clone="git://github.com/JuliaQuant/MarketData.jl.git"
end

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

yaml

--- 
dependencies: 
  - FactChecker
  - git://github.com/JuliaQuant/MarketData.jl.git
tests: 
  - 
    - test/runfirst.jl
    - test/runsecond.jl
  - test/foo.jl
  - test/bar.jl

@StefanKarpinski
Copy link
Member

How about just having a test/REQUIRE file? Same format but it's additional requirements for testing. That seems straightforward enough and gets the job done.

@StefanKarpinski
Copy link
Member

I do like the idea of having this – it seems like something we really need. I'm fine with standardizing on a script name for running tests, but I do prefer test/runtests.jl over test/run_tests.jl.

@porterjamesj
Copy link
Contributor

+1 for test/runtests.jl and test/REQUIRE

@johnmyleswhite
Copy link
Member

Another +1

@StefanKarpinski
Copy link
Member

I'm a bit ambivalent about whether we should just list tests or have a script, but since you're going to be running code anyway, having a runtests.jl script does seem like it provides maximum flexibility. In the future, we can always have something where we look for runtests.jl first but if it doesn't exist, look for some declarative test list.

@mlubin
Copy link
Member

mlubin commented Mar 18, 2014

I'd expect some testing packages to pop up that let you easily implement runtests.jl with a one-liner instead of explicitly looping through the files and including them. So I don't see the harm in the extra flexibility.

@burrowsa
Copy link
Contributor Author

@mlubin funny you should say that, one has already popped up :)

https://github.com/burrowsa/RunTests.jl

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

test/runtests.jl is 👍 for me and has the benefit of being the most common current set up.

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

Does REQUIRE/test/REQUIRE handle non-METADATA packages?

@burrowsa
Copy link
Contributor Author

@IainNZ could that be a separate issue to expand the format of REQUIRE (and hence test/REQUIRE) to support a URL instead of a version?

@IainNZ
Copy link
Member

IainNZ commented Mar 18, 2014

Oh definitely, I was more inquiring as to whether it currently supports it (I thought it might for some reason, which would make life even easier!)

@StefanKarpinski
Copy link
Member

I think it's pretty reasonable to only support registered packages as requirements. It's not like registering a package is particularly onerous – just register it and tag a version.

This was referenced May 14, 2014
@Keno
Copy link
Member

Keno commented Jun 3, 2014

This issue is hilarious with all the references from PackageEvaluator

@IainNZ
Copy link
Member

IainNZ commented Jun 3, 2014

Hah wow, didn't think of that. Was only on that first one-off-mass filing, thank goodness, otherwise it'd be bumped every day!

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.

10 participants