git-contest 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,83 +1,70 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "T005" do
4
-
5
- before(:each) do
6
- init_env
7
- ENV['GIT_CONTEST_HOME'] = get_path('/mock/default_config')
8
- @test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t005"
9
- Dir.mkdir @test_dir
10
- Dir.chdir @test_dir
11
- # ENV['GIT_CONTEST_DEBUG'] = 'ON'
12
- end
13
-
14
- after(:each) do
15
- Dir.chdir '..'
16
- FileUtils.remove_dir @test_dir, :force => true
17
- end
18
-
19
- describe "001" do
20
-
3
+ describe "T005: branching" do
4
+ context "A001" do
21
5
  before do
22
- ENV['GIT_CONTEST_CONFIG'] = get_path('/mock/t005/001/config.yml')
23
- Dir.mkdir '001'
24
- Dir.chdir '001'
25
- end
26
-
27
- describe '001' do
28
-
29
- before do
30
- Dir.mkdir '001'
31
- Dir.chdir '001'
6
+ ENV['GIT_CONTEST_CONFIG'] = "#{@temp_dir}/home/config.yml"
7
+ File.open ENV['GIT_CONTEST_CONFIG'], "w" do |file|
8
+ file.write <<EOF
9
+ sites:
10
+ test_dummy:
11
+ driver: dummy
12
+ user: dummy
13
+ password: dummy
14
+ EOF
32
15
  end
16
+ end
33
17
 
18
+ context 'B001' do
34
19
  it '001: init -> start -> submit -> submit -> finish' do
35
20
  Dir.mkdir 'test1'
36
21
  Dir.chdir 'test1'
22
+
37
23
  # Init
38
24
  bin_exec "init --defaults"
39
- git_current_branch.should === 'master'
25
+ expect(git_current_branch).to eq 'master'
40
26
  ret = git_do "log --oneline"
41
- ret.include?('Initial commit').should === true
27
+ expect(ret).to include 'Initial commit'
28
+
42
29
  # Start
43
30
  bin_exec "start contest1"
44
- git_current_branch.should === 'contest/contest1'
31
+ expect(git_current_branch).to eq 'contest/contest1'
32
+
45
33
  # Edit.1
46
34
  File.open 'main.c', 'w' do |file|
47
35
  file.write 'wa-code'
48
36
  end
37
+
49
38
  # Submit.1
50
39
  bin_exec "submit test_dummy -c 1000 -p A"
51
40
  ret = git_do "log --oneline"
52
- ret.include?('Dummy 1000A: Wrong Answer').should === true
41
+ expect(ret).to include 'Dummy 1000A: Wrong Answer'
42
+
53
43
  ret = git_do "ls-files"
54
- ret.include?('main.c').should === true
44
+ expect(ret).to include 'main.c'
45
+
55
46
  # Edit.2 fixed
56
47
  File.open 'main.c', 'w' do |file|
57
48
  file.write 'ac-code'
58
49
  end
50
+
59
51
  # Submit.2
60
52
  bin_exec "submit test_dummy -c 1000 -p A"
61
53
  ret = git_do "log --oneline"
62
- ret.include?('Dummy 1000A: Accepted').should === true
54
+ expect(ret).to include 'Dummy 1000A: Accepted'
55
+
63
56
  ret = git_do "ls-files"
64
- ret.include?('main.c').should === true
57
+ expect(ret).to include 'main.c'
58
+
65
59
  # Finish
66
60
  bin_exec "finish --no-edit"
67
- git_current_branch.should === 'master'
61
+ expect(git_current_branch).to eq 'master'
62
+
68
63
  ret = git_do "log --oneline"
69
- ret.include?('Dummy 1000A: Wrong Answer').should === true
70
- ret.include?('Dummy 1000A: Accepted').should === true
71
- # Clean
72
- FileUtils.remove_dir '.git', :force => true
73
- FileUtils.remove 'main.c'
74
- Dir.chdir '..'
75
- Dir.rmdir 'test1'
64
+ expect(ret).to include 'Dummy 1000A: Wrong Answer'
65
+ expect(ret).to include 'Dummy 1000A: Accepted'
76
66
  end
77
-
78
67
  end
79
-
80
68
  end
81
-
82
69
  end
83
70
 
@@ -1,42 +1,21 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "T007: git-contest-start" do
4
-
5
- before(:each) do
6
- init_env
7
- @test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t007"
8
- Dir.mkdir @test_dir
9
- Dir.chdir @test_dir
10
- # debug_on
11
- end
12
-
13
- after(:each) do
14
- Dir.chdir '..'
15
- FileUtils.remove_dir @test_dir, :force => true
16
- end
17
-
18
- describe "001: specify based branch" do
19
-
4
+ context "A001: specify based branch" do
20
5
  before do
21
- Dir.mkdir "001"
22
- Dir.chdir "001"
23
6
  bin_exec "init --defaults"
24
7
  end
25
8
 
26
- after do
27
- Dir.chdir ".."
28
- end
29
-
30
9
  it "001" do
31
10
  git_do "checkout -b base1"
32
11
  git_do "commit --allow-empty -m 'this is commit'"
33
12
  git_do "checkout master"
34
13
  bin_exec "start test1"
35
14
  ret1 = git_do "log --oneline"
36
- ret1.include?("this is commit").should === false
15
+ expect(ret1).not_to include "this is commit"
37
16
  bin_exec "start test2 base1"
38
17
  ret2 = git_do "log --oneline"
39
- ret2.include?("this is commit").should === true
18
+ expect(ret2).to include "this is commit"
40
19
  end
41
20
 
42
21
  it "002" do
@@ -45,10 +24,10 @@ describe "T007: git-contest-start" do
45
24
  git_do "checkout master"
46
25
  bin_exec "start test1 base1"
47
26
  ret1 = git_do "log --oneline"
48
- ret1.include?("this is commit").should === true
27
+ expect(ret1).to include "this is commit"
49
28
  bin_exec "start test2"
50
29
  ret2 = git_do "log --oneline"
51
- ret2.include?("this is commit").should === false
30
+ expect(ret2).not_to include "this is commit"
52
31
  end
53
32
 
54
33
  it "003" do
@@ -56,10 +35,10 @@ describe "T007: git-contest-start" do
56
35
  git_do "commit --allow-empty -m 'this is commit'"
57
36
  bin_exec "start test1 base1"
58
37
  ret1 = git_do "log --oneline"
59
- ret1.include?("this is commit").should === true
38
+ expect(ret1).to include "this is commit"
60
39
  bin_exec "start test2"
61
40
  ret2 = git_do "log --oneline"
62
- ret2.include?("this is commit").should === false
41
+ expect(ret2).not_to include "this is commit"
63
42
  end
64
43
 
65
44
  it "004" do
@@ -67,25 +46,14 @@ describe "T007: git-contest-start" do
67
46
  git_do "commit --allow-empty -m 'this is commit'"
68
47
  bin_exec "start test1"
69
48
  ret1 = git_do "log --oneline"
70
- ret1.include?("this is commit").should === false
49
+ expect(ret1).not_to include "this is commit"
71
50
  bin_exec "start test2 base1"
72
51
  ret2 = git_do "log --oneline"
73
- ret2.include?("this is commit").should === true
52
+ expect(ret2).to include "this is commit"
74
53
  end
75
-
76
54
  end
77
55
 
78
- describe "002: --fetch" do
79
-
80
- before do
81
- Dir.mkdir "002"
82
- Dir.chdir "002"
83
- end
84
-
85
- after do
86
- Dir.chdir ".."
87
- end
88
-
56
+ context "A002: --fetch" do
89
57
  it "001" do
90
58
  Dir.mkdir "test1"
91
59
  Dir.chdir "test1"
@@ -95,27 +63,26 @@ describe "T007: git-contest-start" do
95
63
  Dir.chdir "test1"
96
64
  10.times {|x| git_do "commit --allow-empty -m 'this is commit'" }
97
65
  ret1 = git_do "log --oneline master"
66
+ expect(ret1).to include "this is commit"
67
+
98
68
  Dir.chdir ".."
99
69
  Dir.chdir "test2"
100
70
  # init
101
71
  bin_exec "init --defaults"
102
72
  # fetch
103
73
  ret2 = git_do "log --oneline origin/master"
74
+ expect(ret2).not_to include "this is commit"
75
+
104
76
  ret_start1 = bin_exec "start branch1 --fetch"
77
+ expect(ret_start1).not_to include "Summary of actions:"
78
+
105
79
  ret3 = git_do "log --oneline origin/master"
80
+ expect(ret3).to include "this is commit"
81
+
106
82
  git_do "pull origin master"
107
83
  ret_start2 = bin_exec "start branch2 --fetch"
108
- # check
109
- ret1.include?("this is commit").should === true
110
- ret2.include?("this is commit").should === false
111
- ret3.include?("this is commit").should === true
112
- ret_start1.include?("Summary of actions:").should === false
113
- ret_start2.include?("Summary of actions:").should === true
114
- # clean
115
- Dir.chdir ".."
84
+ expect(ret_start2).to include "Summary of actions:"
116
85
  end
117
-
118
86
  end
119
-
120
87
  end
121
88
 
@@ -3,31 +3,7 @@ require "spec_helper"
3
3
  # Do not forget --no-edit option
4
4
 
5
5
  describe "T008: git-contest-finish" do
6
-
7
- before(:each) do
8
- init_env
9
- @test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t008"
10
- Dir.mkdir @test_dir
11
- Dir.chdir @test_dir
12
- # debug_on
13
- end
14
-
15
- after(:each) do
16
- Dir.chdir '..'
17
- FileUtils.remove_dir @test_dir, :force => true
18
- end
19
-
20
- describe "001: --keep" do
21
-
22
- before do
23
- Dir.mkdir "001"
24
- Dir.chdir "001"
25
- end
26
-
27
- after do
28
- Dir.chdir ".."
29
- end
30
-
6
+ context "A001: --keep" do
31
7
  it "001: init -> start -> empty-commits -> finish" do
32
8
  bin_exec "init --defaults"
33
9
  bin_exec "start branch1"
@@ -35,8 +11,8 @@ describe "T008: git-contest-finish" do
35
11
  bin_exec "finish --no-edit"
36
12
  ret1 = git_do "branch"
37
13
  ret_log1 = git_do "log --oneline master"
38
- ret1.include?("branch1").should === false
39
- ret_log1.include?("this is commit").should === true
14
+ expect(ret1).not_to include "branch1"
15
+ expect(ret_log1).to include "this is commit"
40
16
  end
41
17
 
42
18
  it "002: init -> start -> empty-commits -> finish --keep" do
@@ -46,8 +22,8 @@ describe "T008: git-contest-finish" do
46
22
  bin_exec "finish --no-edit --keep"
47
23
  ret1 = git_do "branch"
48
24
  ret_log1 = git_do "log --oneline master"
49
- ret1.include?("branch1").should === true
50
- ret_log1.include?("this is commit").should === true
25
+ expect(ret1).to include "branch1"
26
+ expect(ret_log1).to include "this is commit"
51
27
  end
52
28
 
53
29
  it "003: init -> start -> empty-commits -> finish -k" do
@@ -57,23 +33,13 @@ describe "T008: git-contest-finish" do
57
33
  bin_exec "finish --no-edit -k"
58
34
  ret1 = git_do "branch"
59
35
  ret_log1 = git_do "log --oneline master"
60
- ret1.include?("branch1").should === true
61
- ret_log1.include?("this is commit").should === true
36
+ expect(ret1).to include "branch1"
37
+ expect(ret_log1).to include "this is commit"
62
38
  end
63
39
 
64
40
  end
65
41
 
66
- describe "002: --rebase" do
67
-
68
- before do
69
- Dir.mkdir "002"
70
- Dir.chdir "002"
71
- end
72
-
73
- after do
74
- Dir.chdir ".."
75
- end
76
-
42
+ context "A002: --rebase" do
77
43
  it "001: init -> start -> empty-commits -> finish --rebase" do
78
44
  # create branches: branch1(normal) -> branch2(rebase) -> branch3(normal)
79
45
  bin_exec "init --defaults"
@@ -105,28 +71,18 @@ describe "T008: git-contest-finish" do
105
71
  bin_exec "finish branch3 --no-edit"
106
72
  ret_branch_2 = git_do "branch"
107
73
  ret_log = git_do "log --oneline"
108
- ret_branch_1.include?("branch1").should === true
109
- ret_branch_1.include?("branch2").should === true
110
- ret_branch_1.include?("branch3").should === true
111
- ret_branch_2.include?("branch1").should === false
112
- ret_branch_2.include?("branch2").should === false
113
- ret_branch_2.include?("branch3").should === false
74
+ expect(ret_branch_1).to include "branch1"
75
+ expect(ret_branch_1).to include "branch2"
76
+ expect(ret_branch_1).to include "branch3"
77
+ expect(ret_branch_2).not_to include "branch1"
78
+ expect(ret_branch_2).not_to include "branch2"
79
+ expect(ret_branch_2).not_to include "branch3"
114
80
  (!!ret_log.match(/test-2.*test-3.*test-1/m)).should === true
115
81
  end
116
82
 
117
83
  end
118
84
 
119
- describe "003: --force-delete" do
120
-
121
- before do
122
- Dir.mkdir "003"
123
- Dir.chdir "003"
124
- end
125
-
126
- after do
127
- Dir.chdir ".."
128
- end
129
-
85
+ context "A003: --force-delete" do
130
86
  # TODO: recheck
131
87
  it "001: init -> start -> trigger merge error -> finish --force-delete" do
132
88
  # make conflict
@@ -152,23 +108,12 @@ describe "T008: git-contest-finish" do
152
108
  bin_exec "finish branch1 --no-edit"
153
109
  bin_exec "finish branch2 --force-delete --no-edit"
154
110
  ret_branch = git_do "branch"
155
- ret_branch.include?("contest/branch1").should === false
156
- ret_branch.include?("contest/branch2").should === false
111
+ expect(ret_branch).not_to include "contest/branch1"
112
+ expect(ret_branch).not_to include "contest/branch2"
157
113
  end
158
-
159
114
  end
160
115
 
161
- describe "004: --squash" do
162
-
163
- before do
164
- Dir.mkdir "004"
165
- Dir.chdir "004"
166
- end
167
-
168
- after do
169
- Dir.chdir ".."
170
- end
171
-
116
+ context "A004: --squash" do
172
117
  it "001: init -> start -> empty-commits -> finish --squash" do
173
118
  bin_exec "init --defaults"
174
119
  bin_exec "start branch1"
@@ -181,18 +126,14 @@ describe "T008: git-contest-finish" do
181
126
  bin_exec "finish --no-edit --squash branch1"
182
127
  ret_log1 = git_do "log --oneline"
183
128
  ret_branch1 = git_do "branch"
184
- ret_branch1.include?("branch1").should === false
185
- ret_log1.include?("this is commit").should === true
186
- ret_log1.include?("Squashed commit").should === true
129
+ expect(ret_branch1).not_to include "branch1"
130
+ expect(ret_log1).to include "this is commit"
131
+ expect(ret_log1).to include "Squashed commit"
187
132
  end
188
-
189
133
  end
190
134
 
191
- describe "005: --fetch" do
192
-
135
+ context "A005: --fetch" do
193
136
  before do
194
- Dir.mkdir "005"
195
- Dir.chdir "005"
196
137
  Dir.mkdir "src"
197
138
  Dir.chdir "src"
198
139
  bin_exec "init --defaults"
@@ -200,15 +141,9 @@ describe "T008: git-contest-finish" do
200
141
  10.times {|x| git_do "commit --allow-empty -m 'this is commit #{x}'" }
201
142
  Dir.chdir ".."
202
143
  git_do "clone src dest"
203
-
204
144
  Dir.chdir "dest"
205
145
  end
206
146
 
207
- after do
208
- Dir.chdir ".."
209
- Dir.chdir ".."
210
- end
211
-
212
147
  it "001: init -> start -> clone -> checkout@dest -> empty-commits@dest -> finish@dest" do
213
148
  git_do "checkout -b master origin/master"
214
149
  bin_exec "init --defaults"
@@ -219,11 +154,9 @@ describe "T008: git-contest-finish" do
219
154
  Dir.chdir "src"
220
155
  ret_branch1 = git_do "branch"
221
156
  git_do "checkout master"
222
- ret_branch1.include?('branch1').should === true
223
- ret_branch2.include?('branch1').should === false
157
+ expect(ret_branch1).to include 'branch1'
158
+ expect(ret_branch2).not_to include 'branch1'
224
159
  end
225
-
226
160
  end
227
-
228
161
  end
229
162
 
@@ -3,44 +3,18 @@ require "spec_helper"
3
3
  # Don't forget --defaults option
4
4
 
5
5
  describe "T009: git-contest-init" do
6
-
7
- before do
8
- init_env
9
- @test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t009"
10
- Dir.mkdir @test_dir
11
- Dir.chdir @test_dir
12
- # debug_on
13
- end
14
-
15
- after do
16
- Dir.chdir '..'
17
- Dir.rmdir @test_dir
18
- end
19
-
20
- describe "001: --force" do
21
- before do
22
- Dir.mkdir "001"
23
- Dir.chdir "001"
24
- end
25
-
26
- after do
27
- FileUtils.remove_dir ".git", :force => true
28
- Dir.chdir ".."
29
- Dir.rmdir "001"
30
- end
31
-
6
+ context "A001: --force" do
32
7
  it "001: init -> init" do
33
8
  ret1 = bin_exec "init --defaults"
34
9
  ret_config1 = git_do("config --get git.contest.branch.master")
35
10
  ret2 = bin_exec "init --defaults"
36
-
37
11
  ret_config1.should === "master"
38
- ret1.include?("Error: unknown argument").should === false
39
- ret2.include?("Error: unknown argument").should === false
40
- ret1.include?("Already initialized for git-contest.").should === false
41
- ret1.include?("use: git contest init -f").should === false
42
- ret2.include?("Already initialized for git-contest.").should === true
43
- ret2.include?("use: git contest init -f").should === true
12
+ expect(ret1).not_to include "Error: unknown argument"
13
+ expect(ret2).not_to include "Error: unknown argument"
14
+ expect(ret1).not_to include "Already initialized for git-contest."
15
+ expect(ret1).not_to include "use: git contest init -f"
16
+ expect(ret2).to include "Already initialized for git-contest."
17
+ expect(ret2).to include "use: git contest init -f"
44
18
  end
45
19
 
46
20
  it "002: init -> init -f -> init --force" do
@@ -49,15 +23,15 @@ describe "T009: git-contest-init" do
49
23
  ret2 = bin_exec "init --defaults -f"
50
24
  ret3 = bin_exec "init --defaults --force"
51
25
  ret_config1.should === "master"
52
- ret1.include?("Error: unknown argument").should === false
53
- ret2.include?("Error: unknown argument").should === false
54
- ret3.include?("Error: unknown argument").should === false
55
- ret1.include?("Already initialized for git-contest.").should === false
56
- ret1.include?("use: git contest init -f").should === false
57
- ret2.include?("Already initialized for git-contest.").should === false
58
- ret2.include?("use: git contest init -f").should === false
59
- ret3.include?("Already initialized for git-contest.").should === false
60
- ret3.include?("use: git contest init -f").should === false
26
+ expect(ret1).not_to include "Error: unknown argument"
27
+ expect(ret2).not_to include "Error: unknown argument"
28
+ expect(ret3).not_to include "Error: unknown argument"
29
+ expect(ret1).not_to include "Already initialized for git-contest."
30
+ expect(ret1).not_to include "use: git contest init -f"
31
+ expect(ret2).not_to include "Already initialized for git-contest."
32
+ expect(ret2).not_to include "use: git contest init -f"
33
+ expect(ret3).not_to include "Already initialized for git-contest."
34
+ expect(ret3).not_to include "use: git contest init -f"
61
35
  end
62
36
 
63
37
  it "003: init -f -> init -f -> init --force" do
@@ -66,17 +40,16 @@ describe "T009: git-contest-init" do
66
40
  ret2 = bin_exec "init --defaults -f"
67
41
  ret3 = bin_exec "init --defaults --force"
68
42
  ret_config1.should === "master"
69
- ret1.include?("Error: unknown argument").should === false
70
- ret2.include?("Error: unknown argument").should === false
71
- ret3.include?("Error: unknown argument").should === false
72
- ret1.include?("Already initialized for git-contest.").should === false
73
- ret1.include?("use: git contest init -f").should === false
74
- ret2.include?("Already initialized for git-contest.").should === false
75
- ret2.include?("use: git contest init -f").should === false
76
- ret3.include?("Already initialized for git-contest.").should === false
77
- ret3.include?("use: git contest init -f").should === false
43
+ expect(ret1).not_to include "Error: unknown argument"
44
+ expect(ret2).not_to include "Error: unknown argument"
45
+ expect(ret3).not_to include "Error: unknown argument"
46
+ expect(ret1).not_to include "Already initialized for git-contest."
47
+ expect(ret1).not_to include "use: git contest init -f"
48
+ expect(ret2).not_to include "Already initialized for git-contest."
49
+ expect(ret2).not_to include "use: git contest init -f"
50
+ expect(ret3).not_to include "Already initialized for git-contest."
51
+ expect(ret3).not_to include "use: git contest init -f"
78
52
  end
79
53
  end
80
-
81
54
  end
82
55