Skip to content

Commit bfd4917

Browse files
committed
Fix tests
1 parent 3f2c9b7 commit bfd4917

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

Manifest.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[[Pkg]]
2+
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
3+
4+
[[Test]]
5+
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6+
7+
[[APITest]]
8+
path = "test"
9+

Project.save

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
authors = ["ScottPJones <[email protected]>"]
2-
desc = "Tools to help build a consistent API across various packages, use it, and enquire about it"
3-
keywords = ["package", "module", "API"]
4-
license = "MIT"
51
name = "ModuleInterfaceTools"
62
uuid = "5cb8414e-7aab-5a03-a681-351269c074bf"
3+
keywords = ["package", "module", "API"]
4+
license = "MIT"
5+
desc = "Tools to help build a consistent API across various packages, use it, and enquire about it"
6+
authors = ["ScottPJones <[email protected]>"]
77

88
[deps]
9-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
9+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1010
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ build_script:
4343
- C:\projects\julia\bin\julia -e "VERSION < v\"0.7.0-DEV\" || (using InteractiveUtils);
4444
versioninfo();
4545
if VERSION < v\"0.7.0-DEV.5183\"; Pkg.clone(pwd(), \"ModuleInterfaceTools\");
46-
else; using Pkg; Pkg.up(); end"
46+
else; using Pkg; Pkg.add(pwd()); Pkg.up(); end"
4747

4848
test_script:
4949
- C:\projects\julia\bin\julia -e "VERSION < v\"0.7.0-DEV\" || (using Pkg); Pkg.test(\"ModuleInterfaceTools\")"

src/ModuleInterfaceTools.jl

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,16 @@ m_eval(expr) = m_eval(cur_mod(), expr)
111111
* develop! <names...> # Add functions that are part of the development API (extendible)
112112
* modules <names...> # Add submodule names that are part of the API
113113
114+
* path <paths...> # Add paths to LOAD_PATH
115+
114116
* def <name> <expr> # Same as the @def macro, creates a macro with the given name
115117
116118
"""
117119
macro api(cmd::Symbol)
118120
mod = @static V6_COMPAT ? current_module() : @__MODULE__
119121
cmd == :list ? _api_list(mod) :
120122
cmd == :freeze ? _api_freeze(mod) :
123+
cmd == :test ? _api_test(mod) :
121124
error("@api unrecognized command: $cmd")
122125
end
123126

@@ -132,6 +135,20 @@ function _api_freeze(mod::Module)
132135
nothing
133136
end
134137

138+
function _api_path(curmod, exprs)
139+
for exp in exprs
140+
if isa(exp, Expr) || isa(exp, Symbol)
141+
str = m_eval(curmod, exp)
142+
elseif isa(exp, String)
143+
str = exp
144+
else
145+
error("@api path: syntax error $exp")
146+
end
147+
m_eval(curmod, :( push!(LOAD_PATH, $str) ))
148+
end
149+
nothing
150+
end
151+
135152
const _cmduse = (:use, :use!, :test, :extend, :extend!, :export, :list)
136153
const _cmdadd =
137154
(:modules, :public, :develop, :public!, :develop!, :base, :base!)
@@ -276,15 +293,22 @@ function _api_list(curmod, modules)
276293
nothing
277294
end
278295

296+
_api_test(mod) = m_eval(mod, V6_COMPAT ? :(using Base.Test) : :(using Test))
297+
279298
function _api(curmod::Module, cmd::Symbol, exprs)
280299
cmd == :def && return _api_def(exprs...)
300+
cmd == :path && return _api_path(curmod, exprs)
281301

282302
ind = _ff(_cmdadd, cmd)
283303
ind == 0 || return _add_symbols(curmod, cmd, exprs)
284304

285305
_ff(_cmduse, cmd) == 0 && error("Syntax error: @api $cmd $exprs")
286306

287307
debug[] && print("_api($curmod, $cmd, $exprs)")
308+
309+
# Be nice and set up standard Test
310+
cmd == :test && _api_test(curmod)
311+
288312
modules = SymSet()
289313
for ex in exprs
290314
if isa(ex, Expr) && ex.head == :tuple
@@ -324,9 +348,6 @@ function _api(curmod::Module, cmd::Symbol, exprs)
324348
end
325349
end
326350

327-
# Be nice and set up standard Test
328-
cmd == :test && m_eval(curmod, V6_COMPAT ? :(using Base.Test) : :(using Test))
329-
330351
cpy = (cmd == :use!) || (cmd == :extend!)
331352

332353
cpy && _init_api(curmod)

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
using ModuleInterfaceTools
55

6-
@static V6_COMPAT ? (using Base.Test) : (using Test)
6+
@api test
77

8-
push!(LOAD_PATH, @static V6_COMPAT ? joinpath(Pkg.dir(), "test") : @__DIR__)
8+
@api path (@static V6_COMPAT ? joinpath(Pkg.dir("ModuleInterfaceTools"), "test") : @__DIR__)
99

1010
@api extend APITest
1111

0 commit comments

Comments
 (0)