powershell-pester-4

LOW
maintainer ChrisTX 0 votes scanned 2026-10-31 07:58:04.077835
View on AUR
Why flagged

Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.

Triggered rules

Low Few votes, recently uploaded zero_votes_recent

Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.

PKGBUILD

1# Maintainer: Christian Pfeiffer <cpfeiffer at rev-crew dot info>
2# shellcheck disable=SC2034,SC2154
3# shellcheck shell=bash
4
5pkgname=powershell-pester-4
6_module=Pester
7pkgver=4.10.1
8pkgrel=1
9pkgdesc="Test and mock framework for PowerShell, Pester (version 4)"
10# Gherkin.dll is compiled to a ReadyToRun image for the architecture
11arch=('x86_64' 'aarch64')
12url='https://github.com/pester/Pester'
13license=('Apache-2.0')
14_dotnetsdkver="10.0"
15depends=(
16 powershell
17)
18makedepends=(
19 dotnet-gherkin-5
20 dotnet-sdk-"$_dotnetsdkver"
21)
22makedepends_x86_64=(
23 dotnet-source-built-artifacts-"$_dotnetsdkver"
24)
25# Pester 5 isn't compatible with tests written for Pester 4, like PowerShell's own, which ask for
26# version 4 (Save-Module -Name Pester -MaximumVersion 4.99 in build.psm1). That's the latest stable
27# release, 4.10.1, as Save-Module skips prereleases like 4.10.2-beta1.
28source=("Pester-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz"
29 "pester-failure-lines-core.patch"
30 "pester-tests-new-timespan.patch"
31 "crossgen2-pack.targets"
32 "invoke-tests.ps1")
33sha512sums=('1ca27ad9507547b04a9a6cb51bced6533312acff8a117ea10ac8843f2c25becda30b91c0c5e75693aa7870619238dfae3c86820e4ac04243cc42f7da8b0c37ca'
34 '2139d7b806908ac6eff5af89545a7d5cbf8df2a5dc00704b6f61bc3fc475622e68bd8d37b9e9ba1e67b3b72734344059bbf8993361f4f405718df386f9db35c6'
35 '543cf3242522b2b9a30245776d26d75a0b2722a6ccef98c1c13f2e57f3769c57e8c597784011ee861ede5a8d76b2fddd31bb15d91c544c0f6b33d46487f02fff'
36 '340bfd8bcb4548a6b70954d1d17b5c402c47285979c3f2eae27ff8d3fd0547b54ddf934f41e4a777825a8cc9fc674589760b2f701db11a10c7e17f0af2cf3981'
37 'b15da74ebe8f4e77ef43138d79be28f9adc4ad09ed4b796c3198a54a2583928b4b756c1626ef2fcf63adff07eb3566435bfb28ac3911b7538aa89c165ed610ab')
38b2sums=('7533a4ed44964bcb3878e8a968c86cce9eb6e77a663bf08dee0acbc4ad66d144e76153a5865e008747bb24cfd43f82b6ec5b49748773f6e4109f2a81bcc4dfb8'
39 '995a7fb46b41713c7c391de75d01fbdab414c03193e27a5abc773460b4212932fe84d14080f3cdb83d3fb17356b504aac794271d1d12eb50f00142526d1b4536'
40 '8ee8bc3bbe9a512f1b49c65d0d9a33412deef83ad1ca3145c9edd59097f49034befa7bd5756520375ef1f074011cb33897daefd60017459fb5fe04973f8988c6'
41 '3493eecfb50819af971399abe1e62782ccf28500559d222822bddb91ddac6bf191d7e20abf01dfbcb99f7c51df9356061c8f1687a10700228e7d1f77308e873b'
42 '70d2e695a116fb5d4fecf52bf79f16f4c6c7db64c0244ce04b5de0a185f1ef7c77b5c71f892199f7e531936b8d51f619ac5469cbfc8a31089d5a6861ec7beed5')
43
44_dotnet_env() {
45 export NUGET_PACKAGES="$srcdir/nuget"
46 export DOTNET_CLI_HOME="$srcdir/dotnet-home"
47 export DOTNET_CLI_TELEMETRY_OPTOUT=1
48 export DOTNET_NOLOGO=1
49 # RID of the .NET SDK: arch-x64 for the source-built .NET of Arch, linux-arm64 for Microsoft's build
50 _rid=$(dotnet --info | sed -n -E 's/^ *RID: *//p')
51 _runtimever=$(dotnet --list-runtimes | grep -F "NETCore.App $_dotnetsdkver" | sed -E "s/[[:alnum:]\.]+ ([[:digit:]\.]+) .*/\1/")
52}
53
54prepare() {
55 cd "Pester-$pkgver" || exit
56 # The Gherkin parser comes from dotnet-gherkin-5 instead of the prebuilt one. The one for Windows
57 # PowerShell (legacy) isn't needed, as PowerShell loads the one for .NET (core).
58 rm -r lib/Gherkin/core lib/Gherkin/legacy vendor
59 mkdir lib/Gherkin/core
60 bsdtar -xOf "/usr/share/dotnet/nuget-packages/Gherkin.5.1.0.nupkg" lib/netstandard2.0/Gherkin.dll \
61 >lib/Gherkin/core/Gherkin.dll
62
63 # The archive has CRLF line endings (.gitattributes), the patches from git LF
64 sed -i 's/\r$//' Functions/Output.ps1 Functions/TestResults.Tests.ps1
65 # Exception messages on PowerShell 7 include the parameter name, which the failure output shows on
66 # a line of its own (upstream fix after 4.10.1, released in 4.10.2-beta1)
67 patch -Np1 -i "$srcdir/pester-failure-lines-core.patch"
68 # Tests: New-TimeSpan -mi is ambiguous on PowerShell 7 (-Milliseconds), upstream fix after 4.10.1
69 patch -Np1 -i "$srcdir/pester-tests-new-timespan.patch"
70}
71
72build() {
73 _dotnet_env
74 # The crossgen2 of the .NET runtime, from the source-built artifacts where they're available, which
75 # the SDK gets for a project published with ReadyToRun (see crossgen2-pack.targets)
76 mkdir -p crossgen2 nuget-local
77 local _artifacts
78 for _artifacts in /usr/share/dotnet/source-built-artifacts/Private.SourceBuilt.Artifacts.*.tar.gz; do
79 [[ -f "$_artifacts" ]] || continue
80 bsdtar -xf "$_artifacts" -C nuget-local "Microsoft.NETCore.App.Crossgen2.$_rid.*.nupkg" \
81 "Microsoft.NETCore.App.Runtime.$_rid.*.nupkg"
82 done
83 cd crossgen2 || exit
84 cat >nuget.config <<EOF
85<?xml version="1.0" encoding="utf-8"?>
86<configuration>
87 <packageSources>
88 <clear />
89 <add key="dotnet-source-built" value="$srcdir/nuget-local" />
90 <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
91 </packageSources>
92</configuration>
93EOF
94 cat >crossgen2.csproj <<EOF
95<Project Sdk="Microsoft.NET.Sdk">
96 <PropertyGroup>
97 <TargetFramework>net$_dotnetsdkver</TargetFramework>
98 <RuntimeIdentifier>$_rid</RuntimeIdentifier>
99 <SelfContained>false</SelfContained>
100 <PublishReadyToRun>true</PublishReadyToRun>
101 <DisableTransitiveFrameworkReferenceDownloads>true</DisableTransitiveFrameworkReferenceDownloads>
102 </PropertyGroup>
103</Project>
104EOF
105 dotnet restore -p:CustomAfterMicrosoftCommonTargets="$srcdir/crossgen2-pack.targets"
106 cd "$srcdir" || exit
107
108 # Like powershell's Invoke-ReadyToRunCompiler: against the .NET runtime and PowerShell, which
109 # provides Newtonsoft.Json
110 local _arch
111 case "$CARCH" in
112 x86_64) _arch=x64 ;;
113 aarch64) _arch=arm64 ;;
114 esac
115 "$NUGET_PACKAGES/microsoft.netcore.app.crossgen2.$_rid/$_runtimever/tools/crossgen2" "Pester-$pkgver/lib/Gherkin/core/Gherkin.dll" --out Gherkin.dll \
116 --targetos linux --targetarch "$_arch" -O \
117 -r "/usr/share/dotnet/shared/Microsoft.NETCore.App/$_runtimever/*.dll" -r '/usr/lib/powershell-7/*.dll'
118 mv Gherkin.dll "Pester-$pkgver/lib/Gherkin/core/Gherkin.dll"
119}
120
121check() {
122 # With the user's PowerShell data in $srcdir
123 HOME="$srcdir/home" pwsh -NoProfile -NonInteractive -File "$srcdir/invoke-tests.ps1" -Path "$srcdir/Pester-$pkgver"
124}
125
126# Fails if a binary in $pkgdir, also inside the .nupkg files there, is identical to one of the packages
127# restored from a remote feed like nuget.org into $1, so no prebuilt binary slips in instead of one built
128# from source
129_check_prebuilt() {
130 local _extracted="$srcdir/check-prebuilt" _metadata _file _hash _found=0
131 local _binaries=(-type f '(' -name '*.dll' -o -name '*.exe' -o -name '*.so' -o -name '*.so.*' -o -name '*.dylib' ')')
132 local -A _prebuilt=()
133 while IFS= read -r -d '' _metadata; do
134 grep -qE '"source": *"https?://' "$_metadata" || continue
135 while IFS= read -r -d '' _file; do
136 _prebuilt[$(sha256sum <"$_file")]="${_file#"$1"/}"
137 done < <(find "${_metadata%/*}" "${_binaries[@]}" -print0)
138 done < <(find "$1" -name .nupkg.metadata -print0)
139
140 rm -rf "$_extracted"
141 mkdir -p "$_extracted"
142 while IFS= read -r -d '' _file; do
143 mkdir -p "$_extracted/${_file#"$pkgdir"/}"
144 bsdtar -xf "$_file" -C "$_extracted/${_file#"$pkgdir"/}"
145 done < <(find "$pkgdir" -type f -name '*.nupkg' -print0)
146 while IFS= read -r -d '' _file; do
147 _hash=$(sha256sum <"$_file")
148 if [[ -v "_prebuilt[$_hash]" ]]; then
149 echo "Prebuilt binary: ${_file#"$_extracted"/} is ${_prebuilt[$_hash]}" >&2
150 _found=1
151 fi
152 done < <(find "$pkgdir" "$_extracted" "${_binaries[@]}" -print0)
153 rm -rf "$_extracted"
154 return "$_found"
155}
156
157package() {
158 cd "Pester-$pkgver" || exit
159 # The files of the PowerShell Gallery package (buildPSGalleryPackage.ps1), without the tests
160 # (cleanUpBeforeBuild.ps1)
161 local _destdir="$pkgdir/usr/share/powershell/Modules/$_module/$pkgver"
162 install -dm755 "$_destdir"
163 cp -r --no-preserve=ownership Pester.ps?1 nunit_schema_2.5.xsd junit_schema_4.xsd \
164 bin Functions Dependencies Snippets en-US lib "$_destdir/"
165 find "$_destdir" -name '*.Tests.ps1' -delete
166 install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
167
168 _check_prebuilt "$srcdir/nuget"
169}
170

Scan history

Scanned at (UTC)SeverityRules
2026-10-31 07:58:04 Low 1

Report a package

Reports go to the AURWatch maintainer (one person) and are read by hand. No login required.

0 / 4000
Your suggestion