Pkg.jl: interface for adding a test dependency

Created on 9 Jul 2018  路  12Comments  路  Source: JuliaLang/Pkg.jl

It would be great to have the functionality of #340 exposed in the interactive interface, so that one does not have to manually edit the Project.toml. Eg something like

pkg> add targets.test SomePackage
pkg> rm targets.test SomePackage

or simply add test.

REPL feature sandbox

Most helpful comment

bump on this, it still feels so dang crude to have to manually edit the toml to add the Test package as a test dep when starting a fresh project

All 12 comments

I'd be interested in tackling this. Is the idea to add it as a PR for this repo, then it gets copied into julia main repo?

Right, package features are developed here and then upstreamed (usually by @KristofferC) into the Julia main repo stdlib/Pkg directory. To load a development copy, you'll want to comment out the uuid = entry in the Project.toml file and then run julia --project from there and do import Pkg, although for some reason that has started to give me a conflicting binding error. @JeffBezanson, did you change something that causes Main.Pkg to be definitively resolved to stdlib/Pkg?

@IainNZ, if you haven't started on this yet, you may want to hold off for a bit... I may change things that will conflict significantly with anything you do here. I'm trying to implement #165 but it's leading to a bit of design rethought on targets, alternatives, etc.

Haven't started yet - will follow that. Got ~10 days of down time so no rush.

Related to this, is there (or are you planning to implement) an interface for activating test environment?

Let's say I have JSON in my targets.test.deps but not in deps:

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

[targets.test.deps]
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"

Then how do I debug my tests? If I do include("test/runtests.jl") in REPL started with julia --project it says that ArgumentError: Package JSON not found in current path. Checked with:

julia> versioninfo()
Julia Version 0.7.0-beta2.48
Commit c6a949a9c3 (2018-07-19 18:28 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)

Or is there something wrong in my workflow? Are there better ways to run tests in REPL namespace (i.e., not in subprocess via pkg> test)?

Yes, this is a bit annoying. You could just comment out the [targets.test.deps] and those should then apply to [deps]. @StefanKarpinski has another design idea where all packages are put under [deps] which might help with this.

Yes, I'm working on that and should be done with it today. In this design, targets is just a way of choosing subsets of all the dependencies. So far it seems like a cleaner design in general.

If #531 is the solution for the Project.toml file, then I could imagine

pkg> add test=SomePackage

for

  1. adding SomePackage to [extras], if not already present,
  2. pushing SomePackage to test = in [extras]

Maybe pkg> add SomePackage --target=test?

Or just pkg> add SomePackage target=test (without --)? Similar to how you add keyword arguments to macros in proper Julia.

We may want to do some design work on the pkg REPL syntax. It's grown somewhat organically and now that we have some more experience with what needs to be supported, we can think about it a bit more thoroughly. Since it's an interactive mode, we can make breaking changes.

bump on this, it still feels so dang crude to have to manually edit the toml to add the Test package as a test dep when starting a fresh project

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dpsanders picture dpsanders  路  3Comments

timholy picture timholy  路  4Comments

GregPlowman picture GregPlowman  路  3Comments

KristofferC picture KristofferC  路  4Comments

jlperla picture jlperla  路  3Comments