Skip to content

Commit c017185

Browse files
authored
cleanup specify groups spec (#1006)
1 parent b960842 commit c017185

File tree

1 file changed

+9
-76
lines changed

1 file changed

+9
-76
lines changed

spec/parallel_tests/grouper_spec.rb

Lines changed: 9 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -76,116 +76,49 @@ def call(num_groups, options = {})
7676
)
7777
end
7878

79-
context 'with specific groups provided directly' do
80-
it "groups specify_groups as specified when specify_groups is just one spec" do
79+
context 'specify_groups' do
80+
it "groups with one spec" do
8181
expect(call(3, specify_groups: '1')).to eq([["1"], ["2", "5"], ["3", "4"]])
8282
end
8383

84-
it "groups specify_groups as specified when specify_groups is just multiple specs in one process" do
84+
it "groups with multiple specs in one process" do
8585
expect(call(3, specify_groups: '3,1')).to eq([["3", "1"], ["5"], ["2", "4"]])
8686
end
8787

88-
it "groups specify_groups as specified when specify_groups is multiple specs" do
88+
it "groups with multiple specs and multiple processes" do
8989
expect(call(3, specify_groups: '1,2|4')).to eq([["1", "2"], ["4"], ["3", "5"]])
9090
end
9191

92-
it "specify_groups aborts when number of specs separated by pipe is out of bounds" do
92+
it "aborts when number of specs is higher than number of processes" do
9393
expect do
9494
call(3, specify_groups: '1|2|3|4')
9595
end.to raise_error(
9696
"Number of processes separated by pipe must be less than or equal to the total number of processes"
9797
)
9898
end
9999

100-
it "specify_groups aborts when spec passed in doesn't match existing specs" do
100+
it "aborts when spec passed in doesn't match existing specs" do
101101
expect do
102102
call(3, specify_groups: '1|2|6')
103103
end.to raise_error(
104104
"Could not find [\"6\"] from --specify-groups in the selected files & folders"
105105
)
106106
end
107107

108-
it "specify_groups aborts when spec passed in doesn't match existing specs again" do
109-
expect do
110-
call(3, specify_groups: '1,6|2')
111-
end.to raise_error(
112-
"Could not find [\"6\"] from --specify-groups in the selected files & folders"
113-
)
114-
end
115-
116-
it "specify_groups aborts when number of specs is equal to number passed in" do
108+
it "aborts when number of specs is equal to number of processes and not all specs are used" do
117109
expect do
118110
call(3, specify_groups: '1|2|3')
119111
end.to raise_error(/The specs that aren't run:\n\["4", "5"\]/)
120112
end
121113

122-
it "specify_groups does not abort when the every single spec is specified in it" do
114+
it "does not abort when the every single spec is specified" do
123115
expect(call(3, specify_groups: '1,2|3,4|5')).to eq([["1", "2"], ["3", "4"], ["5"]])
124116
end
125-
end
126-
127-
context 'with specific groups provided through STDIN' do
128-
it "groups specify_groups as specified when specify_groups is just one spec" do
129-
allow($stdin).to receive(:read).and_return("1\n")
130117

131-
expect(call(3, specify_groups: '-')).to eq([["1"], ["2", "5"], ["3", "4"]])
132-
end
133-
134-
it "groups specify_groups as specified when specify_groups is just multiple specs in one process" do
118+
it "can read from stdin" do
135119
allow($stdin).to receive(:read).and_return("3,1\n")
136-
137120
expect(call(3, specify_groups: '-')).to eq([["3", "1"], ["5"], ["2", "4"]])
138121
end
139-
140-
it "groups specify_groups as specified when specify_groups is multiple specs" do
141-
allow($stdin).to receive(:read).and_return("1,2|4\n")
142-
143-
expect(call(3, specify_groups: '-')).to eq([["1", "2"], ["4"], ["3", "5"]])
144-
end
145-
146-
it "specify_groups aborts when number of specs separated by pipe is out of bounds" do
147-
allow($stdin).to receive(:read).and_return("1|2|3|4\n")
148-
149-
expect do
150-
call(3, specify_groups: '-')
151-
end.to raise_error(
152-
"Number of processes separated by pipe must be less than or equal to the total number of processes"
153-
)
154-
end
155-
156-
it "specify_groups aborts when spec passed in doesn't match existing specs" do
157-
allow($stdin).to receive(:read).and_return("1|2|6\n")
158-
159-
expect do
160-
call(3, specify_groups: '-')
161-
end.to raise_error(
162-
"Could not find [\"6\"] from --specify-groups in the selected files & folders"
163-
)
164-
end
165-
166-
it "specify_groups aborts when spec passed in doesn't match existing specs again" do
167-
allow($stdin).to receive(:read).and_return("1,6|2\n")
168-
169-
expect do
170-
call(3, specify_groups: '-')
171-
end.to raise_error(
172-
"Could not find [\"6\"] from --specify-groups in the selected files & folders"
173-
)
174-
end
175-
176-
it "specify_groups aborts when number of specs is equal to number passed in" do
177-
allow($stdin).to receive(:read).and_return("1|2|3\n")
178-
179-
expect do
180-
call(3, specify_groups: '-')
181-
end.to raise_error(/The specs that aren't run:\n\["4", "5"\]/)
182-
end
183-
184-
it "specify_groups does not abort when the every single spec is specified in it" do
185-
allow($stdin).to receive(:read).and_return("1,2|3,4|5\n")
186-
187-
expect(call(3, specify_groups: '-')).to eq([["1", "2"], ["3", "4"], ["5"]])
188-
end
189122
end
190123
end
191124

0 commit comments

Comments
 (0)