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.
- checksums.yaml +5 -13
- data/lib/contest/driver/aizu_online_judge.rb +13 -15
- data/lib/contest/driver/base.rb +5 -0
- data/lib/contest/driver/codeforces.rb +8 -14
- data/lib/contest/driver/kattis.rb +6 -9
- data/lib/contest/driver/uva_online_judge.rb +6 -9
- data/lib/git/contest/version.rb +1 -1
- data/spec/bin/t004_git_contest_submit_spec.rb +64 -58
- data/spec/bin/t005_git_contest_branching_spec.rb +33 -46
- data/spec/bin/t007_git_contest_start_spec.rb +19 -52
- data/spec/bin/t008_git_contest_finish_spec.rb +24 -91
- data/spec/bin/t009_git_contest_init_spec.rb +25 -52
- data/spec/lib/contest/driver/t001_aizu_online_judge_spec.rb +24 -28
- data/spec/lib/contest/driver/t002_codeforces_spec.rb +4 -21
- data/spec/lib/contest/driver/t003_uva_online_judge_spec.rb +15 -28
- data/spec/lib/contest/driver/t010_kattis_spec.rb +2 -14
- data/spec/spec_helper.rb +54 -40
- data/spec/t006_config_spec.rb +115 -76
- metadata +26 -48
- data/spec/mock/t004/config.yml +0 -17
- data/spec/mock/t005/001/config.yml +0 -5
- data/spec/mock/t006/001/001/001/config.yml +0 -8
- data/spec/mock/t006/001/001/002/config.yml +0 -8
- data/spec/mock/t006/001/001/003/config.yml +0 -8
- data/spec/mock/t006/001/002/001/config.yml +0 -8
- data/spec/mock/t006/001/002/002/config.yml +0 -8
- data/spec/mock/t006/001/002/003/config.yml +0 -8
- data/spec/mock/t006/001/003/001/config.yml +0 -9
- data/spec/mock/t006/001/003/002/config.yml +0 -9
- data/spec/mock/t006/001/003/003/config.yml +0 -9
@@ -1,28 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
require 'mechanize'
|
4
3
|
require 'contest/driver/aizu_online_judge'
|
5
4
|
|
6
|
-
describe "T001: AizuOnlineJudge Driver" do
|
7
|
-
before :each do
|
8
|
-
@test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t001"
|
9
|
-
Dir.mkdir @test_dir
|
10
|
-
Dir.chdir @test_dir
|
11
|
-
end
|
12
|
-
|
13
|
-
after :each do
|
14
|
-
Dir.chdir @test_dir
|
15
|
-
Dir.chdir '..'
|
16
|
-
FileUtils.remove_dir @test_dir, :force => true
|
17
|
-
end
|
18
|
-
|
5
|
+
describe "T001: AizuOnlineJudge Driver" do
|
19
6
|
before do
|
20
7
|
# setup driver
|
21
8
|
@driver = Contest::Driver::AizuOnlineJudge.new
|
22
9
|
@driver.stub(:sleep).and_return(0)
|
23
|
-
@driver.client = Mechanize.new {|agent|
|
24
|
-
agent.user_agent_alias = 'Windows IE 7'
|
25
|
-
}
|
26
10
|
ENV['GIT_CONTEST_CONFIG'] = get_path('/mock/t001/config.yml')
|
27
11
|
init
|
28
12
|
|
@@ -72,8 +56,8 @@ describe "T001: AizuOnlineJudge Driver" do
|
|
72
56
|
|
73
57
|
context "A001: #get_status_wait" do
|
74
58
|
it "001: Check Status" do
|
75
|
-
ret = @driver.get_status_wait 'test_user', '111'
|
76
|
-
ret.
|
59
|
+
ret = @driver.send :get_status_wait, 'test_user', '111'
|
60
|
+
expect(ret).to eq "Wrong Answer"
|
77
61
|
end
|
78
62
|
|
79
63
|
it "002: Check Timeout" do
|
@@ -82,9 +66,9 @@ describe "T001: AizuOnlineJudge Driver" do
|
|
82
66
|
@flag = true
|
83
67
|
end
|
84
68
|
@driver.on 'timeout', proc
|
85
|
-
@driver.get_status_wait 'test_user', '999'
|
69
|
+
@driver.send :get_status_wait, 'test_user', '999'
|
86
70
|
@driver.off 'timeout', proc
|
87
|
-
@flag.
|
71
|
+
expect(@flag).to eq true
|
88
72
|
end
|
89
73
|
|
90
74
|
it "002: Check Timeout noset" do
|
@@ -94,8 +78,8 @@ describe "T001: AizuOnlineJudge Driver" do
|
|
94
78
|
end
|
95
79
|
@driver.on 'timeout', proc
|
96
80
|
@driver.off 'timeout', proc
|
97
|
-
@driver.get_status_wait 'test_user', '999'
|
98
|
-
@flag.
|
81
|
+
@driver.send :get_status_wait, 'test_user', '999'
|
82
|
+
expect(@flag).to eq false
|
99
83
|
end
|
100
84
|
end
|
101
85
|
|
@@ -115,10 +99,10 @@ describe "T001: AizuOnlineJudge Driver" do
|
|
115
99
|
end
|
116
100
|
|
117
101
|
it "001: Check Status" do
|
118
|
-
ret = @driver.get_status_wait 'test_user', '111'
|
119
|
-
ret.
|
120
|
-
ret = @driver.get_status_wait 'test_user', '112'
|
121
|
-
ret.
|
102
|
+
ret = @driver.send :get_status_wait, 'test_user', '111'
|
103
|
+
expect(ret).to eq "Wrong Answer"
|
104
|
+
ret = @driver.send :get_status_wait, 'test_user', '112'
|
105
|
+
expect(ret).to eq "Accepted"
|
122
106
|
end
|
123
107
|
end
|
124
108
|
|
@@ -187,7 +171,19 @@ describe "T001: AizuOnlineJudge Driver" do
|
|
187
171
|
@driver.submit()
|
188
172
|
|
189
173
|
@flag = @flag_start && @flag_before_submit && @flag_after_submit && @flag_before_wait && @flag_after_wait && @flag_finish
|
190
|
-
@flag.
|
174
|
+
expect(@flag).to eq true
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "A004: #normalize_problem_id" do
|
179
|
+
it "1234" do
|
180
|
+
expect(@driver.send(:normalize_problem_id, "1234")).to eq "1234"
|
181
|
+
end
|
182
|
+
it "0240" do
|
183
|
+
expect(@driver.send(:normalize_problem_id, "0240")).to eq "0240"
|
184
|
+
end
|
185
|
+
it "10000" do
|
186
|
+
expect(@driver.send(:normalize_problem_id, "10000")).to eq "10000"
|
191
187
|
end
|
192
188
|
end
|
193
189
|
end
|
@@ -1,21 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'contest/driver/codeforces'
|
4
|
-
require 'mechanize'
|
5
4
|
|
6
5
|
describe "T002: Codeforces Driver" do
|
7
|
-
before :each do
|
8
|
-
@test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t002"
|
9
|
-
Dir.mkdir @test_dir
|
10
|
-
Dir.chdir @test_dir
|
11
|
-
end
|
12
|
-
|
13
|
-
after :each do
|
14
|
-
Dir.chdir @test_dir
|
15
|
-
Dir.chdir '..'
|
16
|
-
FileUtils.remove_dir @test_dir, :force => true
|
17
|
-
end
|
18
|
-
|
19
6
|
before(:each) do
|
20
7
|
@driver = Contest::Driver::Codeforces.new
|
21
8
|
@driver.stub(:sleep).and_return(0)
|
@@ -34,15 +21,11 @@ describe "T002: Codeforces Driver" do
|
|
34
21
|
'Content-Type' => 'text/html',
|
35
22
|
},
|
36
23
|
)
|
37
|
-
|
38
|
-
@driver.client = Mechanize.new {|agent|
|
39
|
-
agent.user_agent_alias = 'Windows IE 7'
|
40
|
-
}
|
41
24
|
end
|
42
25
|
|
43
26
|
it "check status" do
|
44
|
-
ret = @driver.get_status_wait 11111, 22222
|
45
|
-
ret.
|
27
|
+
ret = @driver.send :get_status_wait, 11111, 22222
|
28
|
+
expect(ret).to include "Accepted"
|
46
29
|
end
|
47
30
|
end
|
48
31
|
|
@@ -132,7 +115,7 @@ describe "T002: Codeforces Driver" do
|
|
132
115
|
:problem_id => 'A',
|
133
116
|
:source => 'test_source.rb',
|
134
117
|
)
|
135
|
-
@driver.submit.
|
118
|
+
expect(@driver.submit).to include "Codeforces 222222A: Accepted"
|
136
119
|
end
|
137
120
|
|
138
121
|
it "check events" do
|
@@ -192,7 +175,7 @@ describe "T002: Codeforces Driver" do
|
|
192
175
|
@driver.submit
|
193
176
|
|
194
177
|
@flag = @flag_start && @flag_before_login && @flag_after_login && @flag_before_submit && @flag_after_submit && @flag_before_wait && @flag_after_wait && @flag_finish
|
195
|
-
@flag.
|
178
|
+
expect(@flag).to eq true
|
196
179
|
end
|
197
180
|
end
|
198
181
|
end
|
@@ -1,21 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'contest/driver/codeforces'
|
4
|
-
require 'mechanize'
|
5
4
|
|
6
5
|
describe "T003: UvaOnlineJudge Driver" do
|
7
|
-
before :each do
|
8
|
-
@test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t003"
|
9
|
-
Dir.mkdir @test_dir
|
10
|
-
Dir.chdir @test_dir
|
11
|
-
end
|
12
|
-
|
13
|
-
after :each do
|
14
|
-
Dir.chdir @test_dir
|
15
|
-
Dir.chdir '..'
|
16
|
-
FileUtils.remove_dir @test_dir, :force => true
|
17
|
-
end
|
18
|
-
|
19
6
|
before(:each) do
|
20
7
|
@driver = Contest::Driver::UvaOnlineJudge.new
|
21
8
|
@driver.stub(:sleep).and_return(0)
|
@@ -24,19 +11,19 @@ describe "T003: UvaOnlineJudge Driver" do
|
|
24
11
|
context "A001: #get_submission_id" do
|
25
12
|
it "should return last submission id" do
|
26
13
|
ret = @driver.get_submission_id(read_file('/mock/t003/after_submit.html'))
|
27
|
-
ret.
|
14
|
+
expect(ret).to eq '99999'
|
28
15
|
end
|
29
16
|
end
|
30
17
|
|
31
18
|
context "A002: #get_submission_status" do
|
32
19
|
it "Sent to judge" do
|
33
20
|
ret = @driver.get_submission_status('99999', read_file('/mock/t003/my_submissions.sent_to_judge.html'))
|
34
|
-
ret.
|
21
|
+
expect(ret).to eq 'Sent to judge'
|
35
22
|
end
|
36
23
|
|
37
24
|
it "Compilation error" do
|
38
25
|
ret = @driver.get_submission_status('99999', read_file('/mock/t003/my_submissions.compile_error.html'))
|
39
|
-
ret.
|
26
|
+
expect(ret).to eq 'Compilation error'
|
40
27
|
end
|
41
28
|
end
|
42
29
|
|
@@ -125,7 +112,7 @@ describe "T003: UvaOnlineJudge Driver" do
|
|
125
112
|
:problem_id => '333333',
|
126
113
|
:source => 'test_source.java',
|
127
114
|
)
|
128
|
-
@driver.submit.
|
115
|
+
expect(@driver.submit).to include "UVa 333333: Wrong answer"
|
129
116
|
end
|
130
117
|
|
131
118
|
it "Check events" do
|
@@ -173,43 +160,43 @@ describe "T003: UvaOnlineJudge Driver" do
|
|
173
160
|
@driver.submit()
|
174
161
|
|
175
162
|
@flag = @flag_start && @flag_before_submit && @flag_after_submit && @flag_before_wait && @flag_after_wait && @flag_finish
|
176
|
-
@flag.
|
163
|
+
expect(@flag).to eq true
|
177
164
|
end
|
178
165
|
end
|
179
166
|
|
180
167
|
context "A004: #is_wait_status" do
|
181
168
|
context "wait" do
|
182
169
|
it "Sent to judge" do
|
183
|
-
@driver.is_wait_status("Sent to judge").
|
170
|
+
expect(@driver.is_wait_status("Sent to judge")).to be true
|
184
171
|
end
|
185
172
|
it "Running" do
|
186
|
-
@driver.is_wait_status("Running").
|
173
|
+
expect(@driver.is_wait_status("Running")).to be true
|
187
174
|
end
|
188
175
|
it "Compiling" do
|
189
|
-
@driver.is_wait_status("Running").
|
176
|
+
expect(@driver.is_wait_status("Running")).to be true
|
190
177
|
end
|
191
178
|
it "Linking" do
|
192
|
-
@driver.is_wait_status("Linking").
|
179
|
+
expect(@driver.is_wait_status("Linking")).to be true
|
193
180
|
end
|
194
181
|
it "Received" do
|
195
|
-
@driver.is_wait_status("Received").
|
182
|
+
expect(@driver.is_wait_status("Received")).to be true
|
196
183
|
end
|
197
184
|
it "empty" do
|
198
|
-
@driver.is_wait_status("").
|
185
|
+
expect(@driver.is_wait_status("")).to be true
|
199
186
|
end
|
200
187
|
end
|
201
188
|
context "no wait" do
|
202
189
|
it "Accepted" do
|
203
|
-
@driver.is_wait_status("Accepted").
|
190
|
+
expect(@driver.is_wait_status("Accepted")).to be false
|
204
191
|
end
|
205
192
|
it "Compilation error" do
|
206
|
-
@driver.is_wait_status("Compilation error").
|
193
|
+
expect(@driver.is_wait_status("Compilation error")).to be false
|
207
194
|
end
|
208
195
|
it "Wrong answer" do
|
209
|
-
@driver.is_wait_status("Wrong answer").
|
196
|
+
expect(@driver.is_wait_status("Wrong answer")).to be false
|
210
197
|
end
|
211
198
|
it "Runtime error" do
|
212
|
-
@driver.is_wait_status("Runtime error").
|
199
|
+
expect(@driver.is_wait_status("Runtime error")).to be false
|
213
200
|
end
|
214
201
|
end
|
215
202
|
end
|
@@ -1,19 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "contest/driver/kattis"
|
3
3
|
|
4
|
-
describe "T010: Kattis Driver" do
|
5
|
-
before :each do
|
6
|
-
@test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t010"
|
7
|
-
Dir.mkdir @test_dir
|
8
|
-
Dir.chdir @test_dir
|
9
|
-
end
|
10
|
-
|
11
|
-
after :each do
|
12
|
-
Dir.chdir @test_dir
|
13
|
-
Dir.chdir '..'
|
14
|
-
FileUtils.remove_dir @test_dir, :force => true
|
15
|
-
end
|
16
|
-
|
4
|
+
describe "T010: Kattis Driver" do
|
17
5
|
before do
|
18
6
|
@driver = Contest::Driver::Kattis.new
|
19
7
|
@driver.stub(:sleep).and_return(0)
|
@@ -200,7 +188,7 @@ describe "T010: Kattis Driver" do
|
|
200
188
|
@driver.submit
|
201
189
|
|
202
190
|
@flag = @flag_start && @flag_before_login && @flag_after_login && @flag_before_submit && @flag_after_submit && @flag_before_wait && @flag_after_wait && @flag_finish
|
203
|
-
@flag.
|
191
|
+
expect(@flag).to be true
|
204
192
|
end
|
205
193
|
end
|
206
194
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,45 +1,59 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
def get_path path
|
6
|
-
File.expand_path(File.dirname(__FILE__) + path)
|
7
|
-
end
|
8
|
-
|
9
|
-
def bin_path path
|
10
|
-
get_path("/../bin/#{path}")
|
11
|
-
end
|
12
|
-
|
13
|
-
def init_env
|
14
|
-
ENV['TEST_MODE'] = 'TRUE'
|
15
|
-
ENV['PATH'] = bin_path('') + ':' + ENV['PATH']
|
16
|
-
ENV['GIT_CONTEST_HOME'] = "#{ENV['GIT_CONTEST_TEMP_DIR']}/home"
|
17
|
-
end
|
18
|
-
|
19
|
-
def debug_print
|
20
|
-
puts `pwd`
|
21
|
-
puts `ls -a`
|
22
|
-
puts ""
|
23
|
-
end
|
1
|
+
require 'webmock'
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'git/contest/common'
|
24
4
|
|
25
|
-
|
26
|
-
|
5
|
+
module SpecHelpers
|
6
|
+
def read_file path
|
7
|
+
File.read get_path(path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_path path
|
11
|
+
File.expand_path(File.dirname(__FILE__) + path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def bin_path path
|
15
|
+
get_path("/../bin/#{path}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def init_env
|
19
|
+
ENV['TEST_MODE'] = 'TRUE'
|
20
|
+
ENV['PATH'] = bin_path('') + ':' + ENV['PATH']
|
21
|
+
ENV['GIT_CONTEST_HOME'] = get_path('/mock/default_config')
|
22
|
+
end
|
23
|
+
|
24
|
+
def debug_print
|
25
|
+
puts `pwd`
|
26
|
+
puts `ls -a`
|
27
|
+
puts ""
|
28
|
+
end
|
29
|
+
|
30
|
+
def debug_on
|
31
|
+
ENV['GIT_CONTEST_DEBUG'] = 'ON'
|
32
|
+
end
|
33
|
+
|
34
|
+
def bin_exec(args)
|
35
|
+
puts "Commmand: #{bin_path('git-contest')} #{args}" if ENV['GIT_CONTEST_DEBUG'] == 'ON'
|
36
|
+
ret = `#{bin_path('git-contest')} #{args} 2>&1`
|
37
|
+
ret
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_git_contest_config(body)
|
41
|
+
ENV['GIT_CONTEST_CONFIG'] = "#{@temp_dir}/home/config.yml"
|
42
|
+
File.open ENV['GIT_CONTEST_CONFIG'], "w" do |file|
|
43
|
+
file.write body
|
44
|
+
end
|
45
|
+
end
|
27
46
|
end
|
28
47
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
48
|
+
RSpec.configure do |config|
|
49
|
+
config.include SpecHelpers
|
50
|
+
config.before :each do
|
51
|
+
WebMock.disable_net_connect!
|
52
|
+
@temp_dir = `mktemp -d /tmp/XXXXXXXXXXXXX`.strip
|
53
|
+
Dir.chdir "#{@temp_dir}"
|
54
|
+
Dir.mkdir "home"
|
55
|
+
init_env
|
56
|
+
end
|
57
|
+
config.order = 'random'
|
33
58
|
end
|
34
59
|
|
35
|
-
require 'webmock'
|
36
|
-
WebMock.disable_net_connect!
|
37
|
-
|
38
|
-
temp_dir = `mktemp -d /tmp/XXXXXXXXXXXXX`.strip
|
39
|
-
`mkdir #{temp_dir}/home`
|
40
|
-
ENV['GIT_CONTEST_TEMP_DIR'] = temp_dir
|
41
|
-
init_env
|
42
|
-
|
43
|
-
$:.unshift File.expand_path('../../lib', __FILE__)
|
44
|
-
require 'git/contest/common'
|
45
|
-
|
data/spec/t006_config_spec.rb
CHANGED
@@ -1,66 +1,64 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "T006: Config Test" do
|
4
|
-
|
5
|
-
|
6
|
-
init_env
|
7
|
-
ENV['GIT_CONTEST_HOME'] = get_path('/mock/default_config')
|
8
|
-
@test_dir = "#{ENV['GIT_CONTEST_TEMP_DIR']}/t006"
|
9
|
-
Dir.mkdir @test_dir
|
10
|
-
Dir.chdir @test_dir
|
11
|
-
# 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: submit_rules" do
|
20
|
-
|
21
|
-
describe "001: commit_message" do
|
22
|
-
|
3
|
+
describe "T006: Config Test" do
|
4
|
+
context "A001: submit_rules" do
|
5
|
+
context "B001: commit_message" do
|
23
6
|
before do
|
24
|
-
Dir.mkdir '001'
|
25
|
-
Dir.chdir '001'
|
26
7
|
File.open "main.d", "w" do |file|
|
27
8
|
file.write "ac-code"
|
28
9
|
end
|
29
10
|
bin_exec "init --defaults"
|
30
11
|
end
|
31
12
|
|
32
|
-
after do
|
33
|
-
Dir.chdir '..'
|
34
|
-
end
|
35
|
-
|
36
13
|
it "001: ${site} ${problem-id}: ${status}" do
|
37
|
-
|
14
|
+
set_git_contest_config <<EOF
|
15
|
+
submit_rules:
|
16
|
+
message: "${site} ${problem-id}: ${status}"
|
17
|
+
sites:
|
18
|
+
test_dummy:
|
19
|
+
driver: dummy
|
20
|
+
user: dummy
|
21
|
+
password: dummy
|
22
|
+
EOF
|
38
23
|
bin_exec "submit test_dummy -c 100 -p A"
|
39
24
|
ret1 = git_do "log --oneline"
|
40
|
-
ret1.include
|
25
|
+
expect(ret1).to include 'Dummy 100A: Accepted'
|
41
26
|
end
|
42
27
|
|
43
28
|
it "002: ${site}-${problem-id}-${status}" do
|
44
|
-
|
29
|
+
set_git_contest_config <<EOF
|
30
|
+
submit_rules:
|
31
|
+
message: "${site}-${problem-id}-${status}"
|
32
|
+
sites:
|
33
|
+
test_dummy:
|
34
|
+
driver: dummy
|
35
|
+
user: dummy
|
36
|
+
password: dummy
|
37
|
+
EOF
|
45
38
|
bin_exec "submit test_dummy -c 100 -p A"
|
46
39
|
ret1 = git_do "log --oneline"
|
47
|
-
ret1.include
|
40
|
+
expect(ret1).to include 'Dummy-100A-Accepted'
|
48
41
|
end
|
49
42
|
|
50
43
|
it "003: ${status}-${site}" do
|
51
|
-
|
44
|
+
set_git_contest_config <<EOF
|
45
|
+
submit_rules:
|
46
|
+
message: "${status}-${site}"
|
47
|
+
sites:
|
48
|
+
test_dummy:
|
49
|
+
driver: dummy
|
50
|
+
user: dummy
|
51
|
+
password: dummy
|
52
|
+
EOF
|
52
53
|
bin_exec "submit test_dummy -c 100 -p A"
|
53
54
|
ret1 = git_do "log --oneline"
|
54
|
-
ret1.include
|
55
|
+
expect(ret1).to include 'Accepted-Dummy'
|
55
56
|
end
|
56
57
|
|
57
58
|
end
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
context "B002: source" do
|
61
61
|
before do
|
62
|
-
Dir.mkdir '002'
|
63
|
-
Dir.chdir '002'
|
64
62
|
File.open "ac.cpp", "w" do |file|
|
65
63
|
file.write "ac-code"
|
66
64
|
end
|
@@ -73,44 +71,65 @@ describe "T006: Config Test" do
|
|
73
71
|
bin_exec "init --defaults"
|
74
72
|
end
|
75
73
|
|
76
|
-
after do
|
77
|
-
Dir.chdir '..'
|
78
|
-
end
|
79
|
-
|
80
74
|
it "001: ac.*" do
|
81
|
-
|
75
|
+
set_git_contest_config <<EOF
|
76
|
+
submit_rules:
|
77
|
+
source: "ac.*"
|
78
|
+
sites:
|
79
|
+
test_dummy:
|
80
|
+
driver: dummy
|
81
|
+
user: dummy
|
82
|
+
password: dummy
|
83
|
+
EOF
|
82
84
|
bin_exec "submit test_dummy -c 100 -p A"
|
85
|
+
|
83
86
|
ret1 = git_do "log --oneline"
|
87
|
+
expect(ret1).to include 'Dummy 100A: Accepted'
|
88
|
+
|
84
89
|
ret_ls1 = git_do "ls-files"
|
85
|
-
|
86
|
-
ret_ls1.include?('ac.cpp').should === true
|
90
|
+
expect(ret_ls1).to include 'ac.cpp'
|
87
91
|
end
|
88
92
|
|
89
93
|
it "002: wa.*" do
|
90
|
-
|
94
|
+
set_git_contest_config <<EOF
|
95
|
+
submit_rules:
|
96
|
+
source: "wa.*"
|
97
|
+
sites:
|
98
|
+
test_dummy:
|
99
|
+
driver: dummy
|
100
|
+
user: dummy
|
101
|
+
password: dummy
|
102
|
+
EOF
|
91
103
|
bin_exec "submit test_dummy -c 100 -p A"
|
104
|
+
|
92
105
|
ret1 = git_do "log --oneline"
|
106
|
+
expect(ret1).to include 'Dummy 100A: Wrong Answer'
|
107
|
+
|
93
108
|
ret_ls1 = git_do "ls-files"
|
94
|
-
|
95
|
-
ret_ls1.include?('wa.d').should === true
|
109
|
+
expect(ret_ls1).to include 'wa.d'
|
96
110
|
end
|
97
111
|
|
98
112
|
it "003: tle.*" do
|
99
|
-
|
113
|
+
set_git_contest_config <<EOF
|
114
|
+
submit_rules:
|
115
|
+
source: "tle.*"
|
116
|
+
sites:
|
117
|
+
test_dummy:
|
118
|
+
driver: dummy
|
119
|
+
user: dummy
|
120
|
+
password: dummy
|
121
|
+
EOF
|
100
122
|
bin_exec "submit test_dummy -c 100 -p A"
|
101
123
|
ret1 = git_do "log --oneline"
|
124
|
+
expect(ret1).to include 'Dummy 100A: Time Limit Exceeded'
|
125
|
+
|
102
126
|
ret_ls1 = git_do "ls-files"
|
103
|
-
|
104
|
-
ret_ls1.include?('tle.go').should === true
|
127
|
+
expect(ret_ls1).to include 'tle.go'
|
105
128
|
end
|
106
|
-
|
107
129
|
end
|
108
130
|
|
109
|
-
|
110
|
-
|
131
|
+
context "B003: add" do
|
111
132
|
before do
|
112
|
-
Dir.mkdir '003'
|
113
|
-
Dir.chdir '003'
|
114
133
|
File.open "test1.cpp", "w" do |file|
|
115
134
|
file.write "ac-code"
|
116
135
|
end
|
@@ -125,44 +144,64 @@ describe "T006: Config Test" do
|
|
125
144
|
end
|
126
145
|
bin_exec "init --defaults"
|
127
146
|
end
|
128
|
-
|
129
|
-
after do
|
130
|
-
Dir.chdir ".."
|
131
|
-
end
|
132
147
|
|
133
148
|
it "001: test*.cpp input1.txt" do
|
134
|
-
|
149
|
+
set_git_contest_config <<EOF
|
150
|
+
submit_rules:
|
151
|
+
source: "test*.cpp"
|
152
|
+
add: "test*.cpp input1.txt"
|
153
|
+
sites:
|
154
|
+
test_dummy:
|
155
|
+
driver: dummy
|
156
|
+
user: dummy
|
157
|
+
password: dummy
|
158
|
+
EOF
|
135
159
|
bin_exec "submit test_dummy -c 100 -p A"
|
136
160
|
ret1 = git_do "ls-files"
|
137
|
-
ret1.include
|
138
|
-
ret1.include
|
139
|
-
ret1.include
|
140
|
-
ret1.include
|
161
|
+
expect(ret1).to include "test1.cpp"
|
162
|
+
expect(ret1).to include "input1.txt"
|
163
|
+
expect(ret1).not_to include "test2.c"
|
164
|
+
expect(ret1).not_to include "input2.txt"
|
141
165
|
end
|
142
166
|
|
143
167
|
it "002: input2.txt test*.c" do
|
144
|
-
|
168
|
+
set_git_contest_config <<EOF
|
169
|
+
submit_rules:
|
170
|
+
source: "test*.c"
|
171
|
+
add: "input2.txt test*.c"
|
172
|
+
sites:
|
173
|
+
test_dummy:
|
174
|
+
driver: dummy
|
175
|
+
user: dummy
|
176
|
+
password: dummy
|
177
|
+
EOF
|
145
178
|
bin_exec "submit test_dummy -c 100 -p A"
|
146
179
|
ret1 = git_do "ls-files"
|
147
|
-
ret1.include
|
148
|
-
ret1.include
|
149
|
-
ret1.include
|
150
|
-
ret1.include
|
180
|
+
expect(ret1).not_to include "test1.cpp"
|
181
|
+
expect(ret1).not_to include "input1.txt"
|
182
|
+
expect(ret1).to include "test2.c"
|
183
|
+
expect(ret1).to include "input2.txt"
|
151
184
|
end
|
152
185
|
|
153
186
|
it "003: input1.txt test1.cpp test2.c input2.txt" do
|
154
|
-
|
187
|
+
set_git_contest_config <<EOF
|
188
|
+
submit_rules:
|
189
|
+
source: "test*.cpp"
|
190
|
+
add: "input1.txt test1.cpp test2.c input2.txt"
|
191
|
+
sites:
|
192
|
+
test_dummy:
|
193
|
+
driver: dummy
|
194
|
+
user: dummy
|
195
|
+
password: dummy
|
196
|
+
EOF
|
155
197
|
bin_exec "submit test_dummy -c 100 -p A"
|
156
198
|
ret1 = git_do "ls-files"
|
157
|
-
ret1.include
|
158
|
-
ret1.include
|
159
|
-
ret1.include
|
160
|
-
ret1.include
|
199
|
+
expect(ret1).to include "test1.cpp"
|
200
|
+
expect(ret1).to include "input1.txt"
|
201
|
+
expect(ret1).to include "test2.c"
|
202
|
+
expect(ret1).to include "input2.txt"
|
161
203
|
end
|
162
|
-
|
163
204
|
end
|
164
|
-
|
165
205
|
end
|
166
|
-
|
167
206
|
end
|
168
207
|
|