Skip to content

Commit 2683188

Browse files
authored
Fix flaky tests (#124)
1 parent d0fd4ca commit 2683188

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

tests/Integration/ParallelizationIntegrationTest.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,17 @@ public function test_it_can_run_the_command_without_sub_processes(): void
6464
Processing 5 items in segments of 2, batches of 2, 1 round, 1 batch in 1 process
6565
6666
0/5 [>---------------------------] 0% 10 secs/10 secs 10.0 MiB
67-
1/5 [=====>----------------------] 20% 10 secs/10 secs 10.0 MiB
68-
2/5 [===========>----------------] 40% 10 secs/10 secs 10.0 MiB
69-
3/5 [================>-----------] 60% 10 secs/10 secs 10.0 MiB
70-
4/5 [======================>-----] 80% 10 secs/10 secs 10.0 MiB
7167
5/5 [============================] 100% 10 secs/10 secs 10.0 MiB
7268
7369
Processed 5 items.
7470

7571
EOF;
7672

77-
$actual = $this->getOutput($commandTester);
73+
$actual = self::normalizeIntermediateProgressBars(
74+
$this->getOutput($commandTester),
75+
);
7876

79-
self::assertSame($expected, $actual);
77+
self::assertSame($expected, $actual, $actual);
8078
}
8179

8280
public function test_it_uses_a_sub_process_if_only_one_process_is_used(): void
@@ -112,15 +110,15 @@ public function test_it_can_run_the_command_with_multiple_processes(): void
112110
Processing 5 movies in segments of 2, batches of 2, 3 rounds, 3 batches in 2 processes
113111
114112
0/5 [>---------------------------] 0% 10 secs/10 secs 10.0 MiB
115-
2/5 [===========>----------------] 40% 10 secs/10 secs 10.0 MiB
116-
4/5 [======================>-----] 80% 10 secs/10 secs 10.0 MiB
117113
5/5 [============================] 100% 10 secs/10 secs 10.0 MiB
118114
119115
Processed 5 movies.
120116

121117
EOF;
122118

123-
$actual = $this->getOutput($commandTester);
119+
$actual = self::normalizeIntermediateProgressBars(
120+
$this->getOutput($commandTester),
121+
);
124122

125123
self::assertSame($expected, $actual, $actual);
126124
}
@@ -144,8 +142,6 @@ public function test_it_can_run_the_command_with_multiple_processes_in_debug_mod
144142
Processing 5 movies in segments of 2, batches of 2, 3 rounds, 3 batches in 2 processes
145143
146144
0/5 [>---------------------------] 0% 10 secs/10 secs 10.0 MiB
147-
2/5 [===========>----------------] 40% 10 secs/10 secs 10.0 MiB
148-
4/5 [======================>-----] 80% 10 secs/10 secs 10.0 MiB
149145
5/5 [============================] 100% 10 secs/10 secs 10.0 MiB
150146
151147
Processed 5 movies.
@@ -158,10 +154,12 @@ public function test_it_can_run_the_command_with_multiple_processes_in_debug_mod
158154
$expectedCommandStartedLine = "[debug] Command started: '/path/to/php' '/path/to/work-dir/bin/console' 'import:movies' '--child'\n";
159155
$expectedCommandFinishedLine = "[debug] Command finished\n";
160156

161-
$outputWithoutExtraDebugInfo = str_replace(
162-
[$expectedCommandStartedLine, $expectedCommandFinishedLine],
163-
['', ''],
164-
$actual,
157+
$outputWithoutExtraDebugInfo = self::normalizeIntermediateProgressBars(
158+
str_replace(
159+
[$expectedCommandStartedLine, $expectedCommandFinishedLine],
160+
['', ''],
161+
$actual,
162+
),
165163
);
166164

167165
self::assertSame($expectedWithNoDebugMode, $outputWithoutExtraDebugInfo, $outputWithoutExtraDebugInfo);
@@ -216,4 +214,13 @@ private static function normalizeConsolePath(string $output): string
216214
$output,
217215
);
218216
}
217+
218+
private static function normalizeIntermediateProgressBars(string $output): string
219+
{
220+
return preg_replace(
221+
'# *?[1-4]/5 \[[=>-]+\] \d+% 10 secs/10 secs 10.0 MiB\n#',
222+
'',
223+
$output,
224+
);
225+
}
219226
}

0 commit comments

Comments
 (0)