Skip to content

Commit

Permalink
Revise
Browse files Browse the repository at this point in the history
  • Loading branch information
wookay committed Jan 16, 2019
1 parent 6888954 commit 5e7932e
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 52 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ script:
- julia --color=yes runtests.jl jive/s
- julia --color=yes runtests.jl jive/s jive/m start=2
- julia --color=yes -pauto runtests.jl jive/s jive/m start=2
- julia --color=yes -e 'using Jive; runtests(@__DIR__, skip=["jive/onlyonce/heavy.jl", "jive/s", "jive/I"])'
- julia --color=yes -pauto -e 'using Jive; runtests(@__DIR__, skip=["jive/onlyonce/heavy.jl", "jive/s"], node1=["jive/m"])'
- julia --color=yes -e 'using Jive; runtests(@__DIR__, skip=["Example", "jive/onlyonce/heavy.jl", "jive/s", "jive/I"])'
- julia --color=yes -pauto -e 'using Jive; runtests(@__DIR__, skip=["Example", "jive/onlyonce/heavy.jl", "jive/s"], node1=["jive/m"])'

- cd Example
- julia --color=yes --project=. -e 'using Pkg; Pkg.test()' example

after_success:
- if [[ "$TRAVIS_OS_NAME" == linux && "$TRAVIS_JULIA_VERSION" == nightly ]] ; then julia --project=. -e 'using Pkg;
Expand Down
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,23 @@ in the above example, test files are matched for only have `jive/s` `jive/m` and
watch the folders.

```sh
~/.julia/dev/Jive/test $ julia --color=yes -q -i runtests.jl jive/s
1/3 jive/skip/skip-calls.jl
Pass 2 (0.29 seconds)
2/3 jive/skip/skip-functions.jl
Pass 4 (0.02 seconds)
3/3 jive/skip/skip.jl
Pass 4 (0.01 seconds)
✅ All 10 tests have been completed. (0.61 seconds)
julia> watch(@__DIR__, sources=[normpath(@__DIR__,"..","src")]) do path
@info :changed path
runtests(@__DIR__)
end
~/.julia/dev/Jive/test/Example/test $ cat runtests.jl
using Jive
runtests(@__DIR__, skip=["revise.jl"])

~/.julia/dev/Jive/test/Example/test $ cat revise.jl
using Revise, Jive
using Example
watch(@__DIR__, sources=[pathof(Example)]) do path
@info :changed path
revise()
runtests(@__DIR__, skip=["revise.jl"])
end
# Jive.stop(watch)

~/.julia/dev/Jive/test/Example/test $ julia --project=.. -q -i revise.jl example
watching folders ...
- jive/skip
- example
- ../src
```

Expand Down
29 changes: 16 additions & 13 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,23 @@ in the above example, test files are matched for only have `jive/s` `jive/m` and
watch the folders.

```sh
~/.julia/dev/Jive/test $ julia --color=yes -q -i runtests.jl jive/s
1/3 jive/skip/skip-calls.jl
Pass 2 (0.29 seconds)
2/3 jive/skip/skip-functions.jl
Pass 4 (0.02 seconds)
3/3 jive/skip/skip.jl
Pass 4 (0.01 seconds)
✅ All 10 tests have been completed. (0.61 seconds)
julia> watch(@__DIR__, sources=[normpath(@__DIR__,"..","src")]) do path
@info :changed path
runtests(@__DIR__)
end
~/.julia/dev/Jive/test/Example/test $ cat runtests.jl
using Jive
runtests(@__DIR__, skip=["revise.jl"])

~/.julia/dev/Jive/test/Example/test $ cat revise.jl
using Revise, Jive
using Example
watch(@__DIR__, sources=[pathof(Example)]) do path
@info :changed path
revise()
runtests(@__DIR__, skip=["revise.jl"])
end
# Jive.stop(watch)

~/.julia/dev/Jive/test/Example/test $ julia --project=.. -q -i revise.jl example
watching folders ...
- jive/skip
- example
- ../src
```

Expand Down
48 changes: 26 additions & 22 deletions docs/src/watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,40 @@ Jive.watch
Jive.stop
```

```
~/.julia/dev/Jive/test $ julia --color=yes -q -i runtests.jl jive/s
1/3 jive/skip/skip-calls.jl
Pass 2 (0.29 seconds)
2/3 jive/skip/skip-functions.jl
Pass 4 (0.02 seconds)
3/3 jive/skip/skip.jl
Pass 4 (0.01 seconds)
✅ All 10 tests have been completed. (0.61 seconds)
julia> watch(@__DIR__, sources=[normpath(@__DIR__,"..","src")]) do path
@info :changed path
runtests(@__DIR__)
end
```sh
~/.julia/dev/Jive/test/Example/test $ cat runtests.jl
using Jive
runtests(@__DIR__, skip=["revise.jl"])

~/.julia/dev/Jive/test/Example/test $ cat revise.jl
using Revise, Jive
using Example
watch(@__DIR__, sources=[pathof(Example)]) do path
@info :changed path
revise()
runtests(@__DIR__, skip=["revise.jl"])
end
# Jive.stop(watch)

~/.julia/dev/Jive/test/Example/test $ julia --project=.. -q -i revise.jl example
watching folders ...
- jive/skip
- example
- ../src
```

when saving any files in the watching folders, it automatically run tests.

```julia
julia> ┌ Info: changed
└ path = "jive/skip/skip.jl"
1/3 jive/skip/skip-calls.jl
Pass 2 (0.00 seconds)
2/3 jive/skip/skip-functions.jl
Pass 4 (0.01 seconds)
3/3 jive/skip/skip.jl
Pass 4 (0.01 seconds)
✅ All 10 tests have been completed. (0.15 seconds)
└ path = "../src/Example.jl"
1/1 example/test1.jl
Pass 1 (0.26 seconds)
✅ All 1 test has been completed. (0.55 seconds)
┌ Info: changed
└ path = "example/test1.jl"
1/1 example/test1.jl
Pass 1 (0.00 seconds)
✅ All 1 test has been completed. (0.00 seconds)
```

to stop watching
Expand Down
2 changes: 1 addition & 1 deletion src/watch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ watch the folders.
function watch(callback::Function, dir::String; targets=ARGS, sources::Union{Vector{Any},Vector{String}}=[])
(all_files, start_idx) = get_all_files(dir, [], targets)
for src in sources
for (root, dirs, files) in walkdir(src)
for (root, dirs, files) in walkdir(isfile(src) ? dirname(src) : src)
for filename in files
!endswith(filename, ".jl") && continue
subpath = path_separator_to_slash(relpath(normpath(root, filename), dir))
Expand Down
10 changes: 10 additions & 0 deletions test/Example/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = "Example"
uuid = "7aa89a43-15c6-4fe4-aa5a-9f9705f170f6"

[extras]
Jive = "ba5e3d4b-8524-549f-bc71-e76ad9e9deed"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Jive", "Revise"]
5 changes: 5 additions & 0 deletions test/Example/src/Example.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Example

f() = 42

end
8 changes: 8 additions & 0 deletions test/Example/test/example/test1.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module test1

using Test
using Example

@test Example.f() == 42

end
9 changes: 9 additions & 0 deletions test/Example/test/revise.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Revise, Jive
using Example
watch(@__DIR__, sources=[pathof(Example)]) do path
@info :changed path
revise()
runtests(@__DIR__, skip=["revise.jl"])
end
# Jive.stop(watch)

3 changes: 3 additions & 0 deletions test/Example/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Jive
runtests(@__DIR__, skip=["revise.jl"])

2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
using Jive # runtests
runtests(@__DIR__, skip=["jive/onlyonce/heavy.jl"])
runtests(@__DIR__, skip=["jive/onlyonce/heavy.jl", "Example"])

0 comments on commit 5e7932e

Please sign in to comment.