Skip to content

Commit 7dc3dd6

Browse files
authored
Bug: Fix log file handling in test-reruns (#539)
* Update Firefox to version 142.0 * Fix reporting on rerun-tests * Echo rerun-rounds starting from 1, hide rebot stdout * Zip log-files from previous test-rounds * Rename ROBOT_RERUN_FAILED to ROBOT_RERUN_MAX_ROUNDS
1 parent ed65615 commit 7dc3dd6

File tree

5 files changed

+49
-19
lines changed

5 files changed

+49
-19
lines changed

.github/workflows/docker-build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ jobs:
3333
- name: Checkout
3434
uses: actions/checkout@v2
3535
- name: Build image
36-
run:
37-
podman build . --tag $IMAGE_NAME --file Dockerfile
36+
run: podman build . --tag $IMAGE_NAME --file Dockerfile
3837
- name: Basic Test
3938
run: |
4039
podman run --shm-size=1g \
@@ -158,5 +157,5 @@ jobs:
158157
run: |
159158
podman run --user=2000:2000 --shm-size=1g \
160159
-v `pwd`/test/rerun.robot:/opt/robotframework/tests/rerun.robot:Z \
161-
-e ROBOT_RERUN_FAILED=20 \
160+
-e ROBOT_RERUN_MAX_ROUNDS=50 \
162161
$IMAGE_NAME

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ ENV ROBOT_TESTS_DIR /opt/robotframework/tests
1616
ENV ROBOT_WORK_DIR /opt/robotframework/temp
1717

1818
# Set the maximum number of rounds to rerun failed tests
19-
ENV ROBOT_RERUN_FAILED 0
19+
ENV ROBOT_RERUN_MAX_ROUNDS 0
20+
21+
# Options to the rebot command when rerunning failed tests
22+
ENV ROBOT_RERUN_REBOT_OPTIONS ""
2023

2124
# Setup X Window Virtual Framebuffer
2225
ENV SCREEN_COLOUR_DEPTH 24
@@ -44,7 +47,7 @@ ENV DATADRIVER_VERSION 1.11.2
4447
ENV DATETIMETZ_VERSION 1.0.6
4548
ENV MICROSOFT_EDGE_VERSION 139.0.3405.86
4649
ENV FAKER_VERSION 6.0.0
47-
ENV FIREFOX_VERSION 141.0
50+
ENV FIREFOX_VERSION 142.0
4851
ENV FTP_LIBRARY_VERSION 1.9
4952
ENV GECKO_DRIVER_VERSION v0.36.0
5053
ENV IMAP_LIBRARY_VERSION 0.4.11

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* [Testing emails](#testing-emails)
1515
* [Dealing with Datetimes and Timezones](#dealing-with-datetimes-and-timezones)
1616
* [Installing additional dependencies](#installing-additional-dependencies)
17+
* [Rerunning tests](#rerunning-tests)
1718
* [Security consideration](#security-consideration)
1819
* [Continuous integration](#continuous-integration)
1920
* [Azure DevOps pipeline](#ci-azure-devops)
@@ -63,7 +64,7 @@ The versions used are:
6364
* [Robot Framework SeleniumLibrary](https://github.com/robotframework/SeleniumLibrary) 6.7.1
6465
* [Robot Framework SSHLibrary](https://github.com/robotframework/SSHLibrary) 3.8.0
6566
* [Axe Selenium Library](https://github.com/mozilla-services/axe-selenium-python) 2.1.6
66-
* Firefox 141.0
67+
* Firefox 142.0
6768
* [Chrome for Testing](https://googlechromelabs.github.io/chrome-for-testing/) 139.0
6869
* Microsoft Edge 139.0
6970
* [Amazon AWS CLI](https://pypi.org/project/awscli/) 1.42.11
@@ -201,15 +202,15 @@ rpa==1.50.0
201202
202203
### Rerunning tests
203204
204-
Failing tests can be rerun by setting the environment variable `ROBOT_RERUN_FAILED` to a value above 0. All reruns of failed tests are executed without parallelization.
205-
The number in environment variable `ROBOT_RERUN_FAILED` dictates how many rerun-rounds are made at maximum. All rerun-rounds will only test what failed in the previous round.
205+
Failing tests can be rerun by setting the environment variable `ROBOT_RERUN_MAX_ROUNDS` to a value above 0. All reruns of failed tests are executed without parallelization.
206+
The number in environment variable `ROBOT_RERUN_MAX_ROUNDS` dictates how many rerun-rounds are made at maximum. All rerun-rounds will only test what failed in the previous round.
206207
The report files combine the results of all rounds, the last round providing the final result.
207208
208-
The default value for `ROBOT_RERUN_FAILED` is 0, meaning that tests will not be executed again if they fail.
209+
The default value for `ROBOT_RERUN_MAX_ROUNDS` is 0, meaning that tests will not be executed again if they fail.
209210
210211
```sh
211212
docker run \
212-
-e ROBOT_RERUN_FAILED=1 \
213+
-e ROBOT_RERUN_MAX_ROUNDS=1 \
213214
ppodgorsek/robot-framework:latest
214215
```
215216

bin/run-tests-in-virtual-screen.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ fi
5353

5454
ROBOT_EXIT_CODE=$?
5555

56-
if [[ ${ROBOT_EXIT_CODE} -gt 0 ]]
56+
if [ ${ROBOT_EXIT_CODE} -gt 0 ]
5757
then
58-
for ((i = 0 ; i < ${ROBOT_RERUN_FAILED} ; i++ ))
58+
for ((i = 0 ; i < ${ROBOT_RERUN_MAX_ROUNDS} ; i++ ))
5959
do
60-
echo "Rerunning failed tests, round ${i}..."
60+
echo "Rerunning failed tests, round $((i+1))..."
61+
62+
# Store previous run into a tarball as screenshots etc from the previous run are removed by rebot
63+
(cd $ROBOT_REPORTS_FINAL_DIR && tar czf report_run_${i}.tar.gz browser *.html *.xml *.log *.png)
64+
6165
xvfb-run \
6266
--server-args="-screen 0 ${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_COLOUR_DEPTH} -ac" \
6367
robot \
@@ -68,11 +72,16 @@ then
6872
$ROBOT_TESTS_DIR
6973

7074
ROBOT_EXIT_CODE=$?
71-
75+
7276
rebot \
7377
--outputDir $ROBOT_REPORTS_FINAL_DIR \
74-
--merge $ROBOT_REPORTS_FINAL_DIR/output_rerun.xml \
75-
$ROBOT_REPORTS_FINAL_DIR/output.xml
78+
--output $ROBOT_REPORTS_FINAL_DIR/output.xml \
79+
--merge $ROBOT_REPORTS_FINAL_DIR/output.xml \
80+
${ROBOT_RERUN_REBOT_OPTIONS} \
81+
$ROBOT_REPORTS_FINAL_DIR/output_rerun.xml \
82+
> /dev/null
83+
84+
rm $ROBOT_REPORTS_FINAL_DIR/output_rerun.xml
7685

7786
if [ ${ROBOT_EXIT_CODE} -eq 0 ]
7887
then

test/rerun.robot

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
*** Test Cases ***
22

3-
Randomly Fail Test
4-
${rand}= Evaluate random.randint(0,3)
5-
IF ${rand} > 0
3+
Roll Dice 1
4+
${rand}= Evaluate random.randint(1,6)
5+
IF ${rand} > 1
6+
Fail
7+
END
8+
9+
Roll Dice 2
10+
${rand}= Evaluate random.randint(1,6)
11+
IF ${rand} > 1
12+
Fail
13+
END
14+
15+
Roll Dice 3
16+
${rand}= Evaluate random.randint(1,6)
17+
IF ${rand} > 1
18+
Fail
19+
END
20+
21+
Roll Dice 4
22+
${rand}= Evaluate random.randint(1,6)
23+
IF ${rand} > 1
624
Fail
725
END

0 commit comments

Comments
 (0)