|
1 | 1 | import Base.Git
|
| 2 | +include("gitutils.jl") |
2 | 3 |
|
3 | 4 | dir = string("tmp.",randstring())
|
4 | 5 | @test !ispath(dir)
|
5 | 6 | mkdir(dir)
|
6 | 7 | @test isdir(dir)
|
7 |
| -try # ensure directory removal |
8 |
| -cd(dir) do |
| 8 | +try cd(dir) do |
9 | 9 |
|
10 |
| -run(`git init -q`) |
11 |
| -run(`git commit -q --allow-empty -m "initial empty commit"`) |
| 10 | + run(`git init -q`) |
| 11 | + run(`git commit -q --allow-empty -m "initial empty commit"`) |
| 12 | + verify_tree(Dict(), "HEAD") |
| 13 | + verify_work(Dict()) |
12 | 14 |
|
13 |
| -for a=["unchanged","changed","removed"], b=["tracked","untracked"] |
14 |
| - run(`echo -n before` > "$a.$b") |
15 |
| - b == "tracked" && run(`git add $a.$b`) |
16 |
| -end |
| 15 | + # each path can have one of these content in each of head, index, work |
| 16 | + # for a total of length(contents)^3 = 4^3 = 64 combinations. |
| 17 | + # each path can be in any of these 64 "superpositions" before & after |
| 18 | + # for a total of 64^2 = 4096 files needed to test all transitions |
| 19 | + # between before and after superpositions of git repo states. |
17 | 20 |
|
18 |
| -try Git.transact() do |
19 |
| - for a=["added","changed"], b=["tracked","untracked"] |
20 |
| - run(`rm -f $a.$b`) # FIXME: delete this pending #2640 |
21 |
| - run(`echo -n after` > "$a.$b") |
22 |
| - @test isfile("$a.$b") |
23 |
| - @test readall("$a.$b") == "after" |
24 |
| - end |
25 |
| - for b=["tracked","untracked"] |
26 |
| - run(`rm removed.$b`) |
27 |
| - @test !ispath("removed.$b") |
28 |
| - end |
29 |
| - run(`git add added.tracked`) |
30 |
| - throw(nothing) |
31 |
| -end catch x |
32 |
| - is(x,nothing) || rethrow() |
33 |
| -end |
| 21 | + contents = [nothing, "foo", "bar", {"baz"=>"qux"}] |
| 22 | + b = length(contents) |
| 23 | + files = 0:(b^3)^2-1 |
| 24 | + states = [ [ base(b,k,6) => contents[rem(div(k,b^p),b)+1] for k in files ] for p=0:5 ] |
34 | 25 |
|
35 |
| -for a=["unchanged","changed","removed"], b=["tracked","untracked"] |
36 |
| - @test isfile("$a.$b") |
37 |
| - @test readall("$a.$b") == "before" |
38 |
| -end |
39 |
| -for b=["tracked","untracked"] |
40 |
| - @test !ispath("added.$b") |
41 |
| -end |
| 26 | + git_setup(states[1:3]...) |
| 27 | + try Git.transact() do |
| 28 | + git_setup(states[4:6]...) |
| 29 | + throw(nothing) |
| 30 | + end catch x |
| 31 | + is(x,nothing) || rethrow() |
| 32 | + end |
| 33 | + git_verify(states[1:3]...) |
42 | 34 |
|
43 |
| -end # cd |
44 |
| -finally |
45 |
| -run(`rm -rf $dir`) |
46 |
| -end |
| 35 | +end finally run(`rm -rf $dir`) end |
0 commit comments