Skip to content

Commit c98e5d5

Browse files
authored
Remove use of 'head' Unix tool in pcre2grep test (#743)
It's not available on Windows, but we hadn't noticed this because it's provided by the Git for Windows tools which I have installed. This is not good practice to require these tools as a build dependency. I have replaced "head -1" with "pcre2grep -m1 .*" which matches and prints the first line. For consistency, I have made the same change on Unix.
1 parent a80dd59 commit c98e5d5

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.github/workflows/build.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,28 @@ jobs:
129129
matrix:
130130
arch: ["Win32", "x64"]
131131
steps:
132+
- name: Setup
133+
run: |
134+
# GitHub Actions Windows images ship with Git for Windows, which is great,
135+
# but it also pollutes the PATH with a lot of Unix tools which we don't
136+
# want to require as build dependencies. This filters out the Unix tools.
137+
# The GitHub images still include an absolute ton of junk in the PATH,
138+
# but it seems to be rare for unintended dependencies to be added to our
139+
# build scripts, so we can live with it for now.
140+
$PATCHED_PATH = ($env:PATH -split ';' | Where-Object { $_ -notmatch 'C:\\Program Files\\Git\\usr\\bin|C:\\Program Files\\Git\\mingw64\\bin' }) -join ';'
141+
# We can't seem to use $GITHUB_PATH here because that only allows
142+
# appending to the PATH, not replacing it.
143+
echo "PATH=$PATCHED_PATH" >> "$env:GITHUB_ENV"
144+
132145
- name: Checkout
133146
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
134147
with:
135148
submodules: true
136149

137150
- name: Configure
138-
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_C_FLAGS="$CFLAGS_MSVC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A ${{ matrix.arch }}
151+
run: |
152+
echo "PATH=$env:PATH"
153+
cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_C_FLAGS="$CFLAGS_MSVC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A ${{ matrix.arch }}
139154
140155
- name: Build
141156
run: cmake --build build --config Release

RunGrepTest

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ echo "---------------------------- Test 131 -----------------------------" >>tes
728728
echo "RC=$?" >>testtrygrep
729729

730730
echo "---------------------------- Test 132 -----------------------------" >>testtrygrep
731-
(cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; head -1 <&3; exec 3<&-) >>testtrygrep 2>&1
731+
(cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; $valgrind $vjs $pcre2grep -m1 '.*' <&3; exec 3<&-) >>testtrygrep 2>&1
732732
echo "RC=$?" >>testtrygrep
733733

734734
echo "---------------------------- Test 133 -----------------------------" >>testtrygrep

RunGrepTest.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ echo RC=^%ERRORLEVEL%>>testtrygrep
693693
echo ---------------------------- Test 132 ----------------------------->>testtrygrep
694694
:: The Unix tests use fd3 here, but Windows only has StdIn/StdOut/StdErr (which, at the kernel
695695
:: level, are not even numbered). Use a subshell instead.
696-
(pushd %srcdir% & (%pcre2grep% -m1 -A3 "^match" & echo ---& head -1) <testdata/grepinput & popd) >>testtrygrep 2>&1
696+
(pushd %srcdir% & (%pcre2grep% -m1 -A3 "^match" & echo ---& %pcre2grep% -m1 ".*") <testdata/grepinput & popd) >>testtrygrep 2>&1
697697
echo RC=^%ERRORLEVEL%>>testtrygrep
698698

699699
echo ---------------------------- Test 133 ----------------------------->>testtrygrep

0 commit comments

Comments
 (0)