Skip to content

Commit

Permalink
ci: add perl DEV job
Browse files Browse the repository at this point in the history
Validates Perl compatibility
  • Loading branch information
carenas committed Sep 30, 2024
1 parent d704ee4 commit 8a26ec4
Show file tree
Hide file tree
Showing 7 changed files with 1,633 additions and 1,547 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,34 @@ jobs:
run: |
./autogen.sh
./maint/ManyConfigTests
camel:
name: perl
runs-on: ubuntu-latest
container: perl:arm32v7/devel
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: yes

- name: Prepare
run: |
apt-get -qq update
apt-get -qq install cmake ninja-build
- name: Configure
run: cmake -G Ninja -B build -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_DEBUG=ON

- name: Build
run: cmake --build build

- name: Test
env:
PCRETEST: build/pcre2test
run: |
cd build
ctest .
cd ..
perl -v
maint/RunPerlTest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ testtemp1grep
testtemp2
testtemp2grep
testtry
testtry2
testtrygrep
testSinput
testbtables
Expand Down
16 changes: 8 additions & 8 deletions maint/GenerateTest26.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def to_string_char(ch_idx):
# UNICODE SCRIPT EXTENSION TESTS
# ---------------------------------------------------------------------------

write_both("# Unicode Script Extension tests.\n\n")
write_both("# Unicode Script Extension tests.\n\n#perltest\n\n")

def gen_script_tests():
script_data = [None] * len(script_names)
Expand Down Expand Up @@ -132,12 +132,12 @@ def gen_script_tests():

write_both("# Base script check\n")
write_both("/^\\p{sc=%s}/utf\n" % script_name)
write_both(" %s\n" % to_string_char(rec[0]))
write_both(" %s\n" % to_string_char(rec[0]))
output_file.write(" 0: %s\n" % to_string_char(rec[0]))
write_both("\n")

write_both("/^\\p{Script=%s}/utf\n" % script_abbrev)
write_both(" %s\n" % to_string_char(rec[1]))
write_both(" %s\n" % to_string_char(rec[1]))
output_file.write(" 0: %s\n" % to_string_char(rec[1]))
write_both("\n")

Expand All @@ -148,12 +148,12 @@ def gen_script_tests():

write_both("# Script extension check\n")
write_both("/^\\p{%s}/utf\n" % script_name)
write_both(" %s\n" % to_string_char(rec[2]))
write_both(" %s\n" % to_string_char(rec[2]))
output_file.write(" 0: %s\n" % to_string_char(rec[2]))
write_both("\n")

write_both("/^\\p{%s=%s}/utf\n" % (property_name, script_abbrev))
write_both(" %s\n" % to_string_char(rec[3]))
write_both(" %s\n" % to_string_char(rec[3]))
output_file.write(" 0: %s\n" % to_string_char(rec[3]))
write_both("\n")

Expand All @@ -162,12 +162,12 @@ def gen_script_tests():
if rec[4] != None:
write_both("# Script extension only character\n")
write_both("/^\\p{%s}/utf\n" % script_name)
write_both(" %s\n" % to_string_char(rec[4]))
write_both(" %s\n" % to_string_char(rec[4]))
output_file.write(" 0: %s\n" % to_string_char(rec[4]))
write_both("\n")

write_both("/^\\p{sc=%s}/utf\n" % script_name)
write_both(" %s\n" % to_string_char(rec[4]))
write_both(" %s\n" % to_string_char(rec[4]))
output_file.write("No match\n")
write_both("\n")
else:
Expand All @@ -178,7 +178,7 @@ def gen_script_tests():
high = rec[3]
write_both("# Character not in script\n")
write_both("/^\\p{%s}/utf\n" % script_name)
write_both(" %s\n" % to_string_char(high + 1))
write_both(" %s\n" % to_string_char(high + 1))
output_file.write("No match\n")
write_both("\n")

Expand Down
79 changes: 64 additions & 15 deletions maint/RunPerlTest
Original file line number Diff line number Diff line change
@@ -1,31 +1,80 @@
#! /bin/sh

# Script to run the Perl-compatible PCRE2 tests through Perl. The argument can
# be "1" or "4" to run just a single test. Otherwise it runs both. This script
# should be run with the main PCRE2 directory current.
# Script to run the Perl-compatible PCRE2 tests through Perl. For testing
# with different versions of Perl, if the first argument is "-perl" then the
# second is taken as the Perl command to use, and both are then removed.
#
# The argument can be the number of the specific Perl compatible test to run
# (ex: "1", "4" or "26") to invoke just one testi, otherwise it runs all and
# returns their status.

if [ "$1" != "4" ]; then
# This script should be run with the main PCRE2 directory current. It needs
# pcre2test for Unicode version compatibility detection and so will use a
# provided PCRETEST variable pointing to it.

if [ -z "$PCRETEST" ]; then
if [ -x pcre2test ]; then
PCRETEST=$(readlink -f pcre2test)
else
PCRETEST=pcre2test
fi
fi

if [ "$1" = "-perl" ]; then
PERL="$2"
ARGS="$1 $PERL"
shift 2
else
PERL=perl
ARGS=""
fi

RC=0

if [ -z "$1" ] || [ "$1" = "1" ]; then
echo "-----------------------------------------------------------------"
echo "Perl test: main functionality (PCRE2 test 1)"
./perltest.sh testdata/testinput1 testtry
if [ $? = 0 ] ; then
tail -n +3 testtry > testtry3
diff -u testdata/testoutput1 testtry3
/bin/rm -rf testtry3
if ./perltest.sh $ARGS testdata/testinput1 testtry; then
tail -n +2 testtry > testtry2
diff -u testdata/testoutput1 testtry2 || RC=33
/bin/rm -rf testtry2
else
RC=1
fi
echo ""
fi

if [ "$1" != "1" ]; then
if [ -z "$1" ] || [ "$1" = "4" ]; then
echo "-----------------------------------------------------------------"
echo "Perl test: UTF-8 and Unicode property features (PCRE2 test 4)"
./perltest.sh -utf8 testdata/testinput4 testtry
if [ $? = 0 ] ; then
tail -n +3 testtry > testtry3
diff -u testdata/testoutput4 testtry3
/bin/rm -rf testtry3
if ./perltest.sh $ARGS -utf8 testdata/testinput4 testtry; then
tail -n +2 testtry > testtry2
diff -u testdata/testoutput4 testtry2 || RC=36
/bin/rm -rf testtry2
else
RC=4
fi
echo ""
fi

if [ -z "$1" ] || [ "$1" = "26" ]; then
echo "-----------------------------------------------------------------"
echo "Perl test: Unicode property tests (PCRE2 test 26)"
U=$($PCRETEST -C | $PERL -ne 'print "$1\n" if /\(Unicode version ([\d.]+)\)/')
P=$($PERL -MUnicode::UCD -e 'print Unicode::UCD::UnicodeVersion, "\n"')
if [ "$U" != "$P" ]; then
echo "SKIPPED: Perl uses Unicode $P but this test expects $U"
else
if ./perltest.sh $ARGS testdata/testinput26 testtry; then
tail -n +2 testtry > testtry2
diff -u testdata/testoutput26 testtry2 || RC=58
/bin/rm -rf testtry2
else
RC=26
fi
echo ""
fi
fi

exit $RC
# End
5 changes: 3 additions & 2 deletions perltest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ fi

(echo "$prefix" ; cat <<'PERLEND'
# The alpha assertions currently give warnings even when -w is not specified.
# Avoid warnings for some of the experimental features that are being used.
no warnings "experimental::alpha_assertions";
no warnings "experimental::script_run";
no warnings "experimental::vlb";
# Function for turning a string into a string of printing chars.
Expand Down Expand Up @@ -143,7 +144,7 @@ if (@ARGV > 1)
}
else { $outfile = "STDOUT"; }
printf($outfile "Perl $^V\n\n");
printf($outfile "Perl $^V\n");
$extra_modifiers = "";
$default_show_mark = 0;
Expand Down
Loading

0 comments on commit 8a26ec4

Please sign in to comment.