Skip to content

Commit 3a01f8e

Browse files
authored
Merge branch 'main' into bug-2052696-harmony
2 parents b0ecd52 + 1816a4b commit 3a01f8e

4 files changed

Lines changed: 70 additions & 14 deletions

File tree

docker/images/Dockerfile.perl-testsuite

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,30 @@ RUN apt-get update && apt-get -y dist-upgrade && \
2929
unzip wget && \
3030
rm -rf /var/lib/apt/lists/*
3131

32-
# Copy the source code
33-
COPY . /app/
32+
# Copy just enough to get the list of dependencies
33+
COPY Bugzilla.pm Makefile.PL gen-cpanfile.pl /app/
3434

3535
# Run Makefile.PL and install dependencies
3636
RUN perl Makefile.PL && \
3737
cpanm --notest --quiet --local-lib="/app/local" Module::CPANfile && \
3838
make cpanfile GEN_CPANFILE_ARGS='-A -U oracle -U mariadb -U pg -U mysql' && \
3939
cpanm --notest --quiet --local-lib="/app/local" -f --installdeps .
4040

41+
# Now copy all of the source. Splitting it from the dependency-related files
42+
# above allows Docker to cache the dependency install step unless the
43+
# dependencies change, saving a *lot* of build time when you just want to run
44+
# tests
45+
COPY . /app/
46+
4147
# Run checksetup
4248
RUN perl checksetup.pl --no-database --default-localconfig --no-templates
4349

44-
# Set the default command to run tests
45-
ENTRYPOINT ["prove", "-Ilocal/lib/perl5", "t"]
46-
CMD []
50+
# Support both prove (default) and perl commands via a dispatcher script.
51+
# the perl option is so you can do `perl -c` on a file in the container
52+
# to make sure it compiles when you don't have dependencies on the host
53+
# machine.
54+
COPY docker/images/perl-testsuite-entrypoint.sh /usr/local/bin/perl-testsuite-entrypoint
55+
RUN chmod +x /usr/local/bin/perl-testsuite-entrypoint
56+
57+
ENTRYPOINT ["/usr/local/bin/perl-testsuite-entrypoint"]
58+
CMD ["t"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
if [ "$#" -eq 0 ]; then
5+
exec prove -Ilocal/lib/perl5 t
6+
fi
7+
8+
case "$1" in
9+
prove)
10+
shift
11+
exec prove -Ilocal/lib/perl5 "$@"
12+
;;
13+
perl)
14+
shift
15+
exec perl -I/app -I/app/local/lib/perl5 "$@"
16+
;;
17+
*)
18+
exec prove -Ilocal/lib/perl5 "$@"
19+
;;
20+
esac

docker/run-tests-in-docker.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export CIRCLE_BUILD_URL=""
1616

1717
TEST_NAME="test_bmo"
1818
DOCKER_COMPOSE_FILE=docker-compose.test-mysql.yml
19+
DEFAULT_TEST_ARGS=(-q -f t/bmo/*.t)
20+
SUITE_ARGS=()
1921
if [ "$#" -eq 0 ]; then
2022
echo "Available test options:"
2123
echo " 1) sanity - Run sanity tests"
@@ -36,28 +38,41 @@ if [ "$#" -eq 0 ]; then
3638
*) echo "Invalid choice. Using default (mysql)"; set -- "mysql" ;;
3739
esac
3840
fi
39-
if [ "$1" == "sanity" ]; then
41+
SUITE="$1"
42+
shift
43+
SUITE_ARGS=("$@")
44+
45+
if [ "$SUITE" == "sanity" ]; then
4046
DOCKER_COMPOSE_FILE=docker-compose.test-mysql.yml
4147
TEST_NAME="test_sanity"
42-
elif [ "$1" == "mysql" ]; then
48+
elif [ "$SUITE" == "mysql" ]; then
4349
DOCKER_COMPOSE_FILE=docker-compose.test-mysql.yml
44-
elif [ "$1" == "pg" ]; then
50+
elif [ "$SUITE" == "pg" ]; then
4551
DOCKER_COMPOSE_FILE=docker-compose.test-pg.yml
46-
elif [ "$1" == "sqlite" ]; then
52+
elif [ "$SUITE" == "sqlite" ]; then
4753
DOCKER_COMPOSE_FILE=docker-compose.test-sqlite.yml
48-
elif [ "$1" == "mariadb" ]; then
54+
elif [ "$SUITE" == "mariadb" ]; then
4955
DOCKER_COMPOSE_FILE=docker-compose.test-mariadb.yml
50-
elif [ "$1" == "release" ]; then
56+
elif [ "$SUITE" == "release" ]; then
5157
DOCKER_FILE=docker/images/Dockerfile.perl-testsuite
5258
if $DOCKER build -t bugzilla-release-test -f "$DOCKER_FILE" .; then
53-
$DOCKER run --rm bugzilla-release-test
59+
$DOCKER run --rm bugzilla-release-test "${SUITE_ARGS[@]}"
5460
else
5561
echo "docker build failed."
5662
fi
5763
exit $?
64+
else
65+
echo "Unknown test suite: $SUITE"
66+
echo "Usage: $0 [sanity|mysql|pg|sqlite|mariadb|release] [suite args...]"
67+
exit 1
5868
fi
69+
70+
if [ "${#SUITE_ARGS[@]}" -eq 0 ]; then
71+
SUITE_ARGS=("${DEFAULT_TEST_ARGS[@]}")
72+
fi
73+
5974
if $DOCKER compose -f "$DOCKER_COMPOSE_FILE" build; then
60-
if $DOCKER compose -f "$DOCKER_COMPOSE_FILE" run --rm --name bugzilla6.test bugzilla6.test "$TEST_NAME" -q -f t/bmo/*.t; then
75+
if $DOCKER compose -f "$DOCKER_COMPOSE_FILE" run --rm --name bugzilla6.test bugzilla6.test "$TEST_NAME" "${SUITE_ARGS[@]}"; then
6176
$DOCKER compose -f "$DOCKER_COMPOSE_FILE" down
6277
else
6378
echo "docker compose run failed."

t/markdown.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ my $angle_link_dom = Mojo::DOM->new($angle_link);
8484
my $ahref = $angle_link_dom->at('a[href]');
8585
is($ahref->attr('href'), 'https://searchfox.org/mozilla-central/rev/76fe4bb385348d3f45bbebcf69ba8c7283dfcec7/mobile/android/base/java/org/mozilla/gecko/toolbar/SecurityModeUtil.java#101', 'angle links are parsed properly');
8686

87-
is($parser->render_html('<foo>'), "<p>&lt;foo&gt;</p>\n", "literal tags work");
87+
# Test that literal tags are not parsed as HTML, but are instead escaped.
88+
# Need to use a tag that is not likely to get used in a real use case,
89+
# because the bug_format_comment extension hook is allowed to arbitrarily
90+
# modify the comment text, and we don't want to accidentally break a real
91+
# use case where the tag contents might get modified and break our test.
92+
is(
93+
$parser->render_html('<markdownliteraltesttoken>'),
94+
"<p>&lt;markdownliteraltesttoken&gt;</p>\n",
95+
'literal tags work'
96+
);
8897

8998
done_testing;

0 commit comments

Comments
 (0)