Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 18 additions & 73 deletions .github/workflows/msys2-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ permissions:
contents: read

jobs:
package:
name: Build MSYS2 package (UCRT64)
build:
name: Build on MSYS2 UCRT64
runs-on: windows-latest

defaults:
Expand All @@ -25,91 +25,34 @@ jobs:
- name: Check out source
uses: actions/checkout@v4

- name: Verify VERSION matches PKGBUILD
id: version
shell: bash
run: |
version_file="$(tr -d '[:space:]' < VERSION)"
pkg_version="${version_file//-/.}"

if ! grep -Fq "_distver=\"${version_file}\"" packaging/msys2/PKGBUILD; then
echo "PKGBUILD _distver does not match VERSION (${version_file})" >&2
exit 1
fi

if ! grep -Eq "^pkgver=${pkg_version//./\\.}$" packaging/msys2/PKGBUILD; then
echo "PKGBUILD pkgver does not match VERSION (${pkg_version})" >&2
exit 1
fi

echo "dist_dir=cunit-${version_file}" >> "${GITHUB_OUTPUT}"
echo "dist_file=cunit-${version_file}" >> "${GITHUB_OUTPUT}"

- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MSYS
msystem: UCRT64
update: true
cache: true
install: >-
base-devel
git

- name: Create source tarball for PKGBUILD
env:
DIST_DIR: ${{ steps.version.outputs.dist_dir }}
DIST_FILE: ${{ steps.version.outputs.dist_file }}
working-directory: packaging/msys2
run: |
git -C ../.. archive \
--format=tar.gz \
--prefix="${DIST_DIR}/" \
HEAD > "${DIST_FILE}.tar.gz"

- name: Build package
working-directory: packaging/msys2
run: MINGW_ARCH=ucrt64 makepkg-mingw -sCLf --noconfirm

- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: cunit-msys2-ucrt64-pkg
path: packaging/msys2/*.pkg.tar.zst
if-no-files-found: error

test-package:
name: Test installed MSYS2 package (UCRT64)
runs-on: windows-latest
needs: package

defaults:
run:
shell: msys2 {0}

steps:
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
cache: true
install: >-
mingw-w64-ucrt-x86_64-autotools
mingw-w64-ucrt-x86_64-cc
mingw-w64-ucrt-x86_64-pkgconf

- name: Download package artifact
uses: actions/download-artifact@v4
with:
name: cunit-msys2-ucrt64-pkg
path: pkg
- name: Bootstrap and configure
run: ./bootstrap --configure --prefix "$(pwd)/_install" -- --enable-debug --enable-test

- name: Build
run: make -j"$(nproc)"

- name: Install package artifact
- name: Run internal self-tests
run: |
pacman -U --noconfirm pkg/*.pkg.tar.zst
test -f "${MINGW_PREFIX}/include/CUnit/CUnit.h"
test -f "${MINGW_PREFIX}/lib/libcunit.a" || test -f "${MINGW_PREFIX}/lib/libcunit.dll.a"
./CUnit/Sources/Test/test_cunit | tee test_cunit.log
grep -q "Failures: 0" test_cunit.log

- name: Install
run: make install

- name: Smoke test installed package
- name: Smoke test installed package metadata
run: |
cat > smoke.c <<'EOF'
#include <CUnit/CUnit.h>
Expand All @@ -123,5 +66,7 @@ jobs:
}
EOF

export PATH="$(pwd)/_install/bin:${PATH}"
export PKG_CONFIG_PATH="$(pwd)/_install/lib/pkgconfig"
gcc smoke.c -o smoke $(pkgconf --cflags --libs cunit)
./smoke
139 changes: 120 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name: CUnit Release

on:
workflow_dispatch:
inputs:
release_tag:
description: 'Optional tag name to validate, for example v2.1.3. Defaults to VERSION.'
required: false
type: string
push:
tags:
- 'v*'

permissions:
contents: write
contents: read

jobs:
verify-version:
Expand All @@ -15,6 +21,7 @@ jobs:
outputs:
version_file: ${{ steps.verify.outputs.version_file }}
pkg_version: ${{ steps.verify.outputs.pkg_version }}
release_tag: ${{ steps.verify.outputs.release_tag }}
dist_dir: ${{ steps.verify.outputs.dist_dir }}
dist_file: ${{ steps.verify.outputs.dist_file }}

Expand All @@ -24,39 +31,99 @@ jobs:

- name: Verify tag matches VERSION
id: verify
env:
INPUT_RELEASE_TAG: ${{ inputs.release_tag }}
shell: bash
run: |
version_file="$(tr -d '[:space:]' < VERSION)"
pkg_version="${version_file//-/.}"
expected_tag="v${pkg_version}"
release_tag="${GITHUB_REF_NAME}"

if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
release_tag="${INPUT_RELEASE_TAG}"
if [ -z "${release_tag}" ]; then
release_tag="${expected_tag}"
fi
fi

if [ "${GITHUB_REF_NAME}" != "${expected_tag}" ]; then
if [ "${release_tag}" != "${expected_tag}" ]; then
echo "Tag/version mismatch" >&2
echo " VERSION file: ${version_file}" >&2
echo " Expected tag: ${expected_tag}" >&2
echo " Actual tag: ${GITHUB_REF_NAME}" >&2
echo " Actual tag: ${release_tag}" >&2
exit 1
fi

if ! grep -Fq '_distver="$(tr -d' packaging/msys2/PKGBUILD || \
! grep -Fq '< ../../VERSION)' packaging/msys2/PKGBUILD; then
echo "PKGBUILD _distver is not read from VERSION" >&2
exit 1
fi

if ! grep -Fq "_distver=\"${version_file}\"" packaging/msys2/PKGBUILD; then
echo "PKGBUILD _distver does not match VERSION (${version_file})" >&2
if ! grep -Fq 'pkgver=${_distver//-/.}' packaging/msys2/PKGBUILD; then
echo "PKGBUILD pkgver is not derived from _distver" >&2
exit 1
fi

if ! grep -Eq "^pkgver=${pkg_version//./\\.}$" packaging/msys2/PKGBUILD; then
echo "PKGBUILD pkgver does not match VERSION (${pkg_version})" >&2
if ! grep -Fq 'm4_esyscmd_s([cat VERSION])' configure.in; then
echo "configure.in does not read VERSION for AC_INIT" >&2
exit 1
fi

echo "version_file=${version_file}" >> "${GITHUB_OUTPUT}"
echo "pkg_version=${pkg_version}" >> "${GITHUB_OUTPUT}"
echo "release_tag=${release_tag}" >> "${GITHUB_OUTPUT}"
echo "dist_dir=cunit-${version_file}" >> "${GITHUB_OUTPUT}"
echo "dist_file=cunit-${version_file}" >> "${GITHUB_OUTPUT}"

source-dist:
name: Build source dist
runs-on: ubuntu-latest
needs: verify-version

steps:
- name: Check out source
uses: actions/checkout@v4

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
autoconf \
automake \
build-essential \
libtool

- name: Bootstrap
run: ./bootstrap --configure --prefix "${RUNNER_TEMP}/cunit-distcheck" -- --enable-debug --enable-test

- name: Build and check source dist
run: make distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-debug --enable-test"

- name: Verify source dist contents
env:
DIST_FILE: ${{ needs.verify-version.outputs.dist_file }}
run: |
test -f "${DIST_FILE}.tar.gz"
tar -tzf "${DIST_FILE}.tar.gz" | grep -Fx "${DIST_FILE}/configure"
tar -tzf "${DIST_FILE}.tar.gz" | grep -Fx "${DIST_FILE}/Makefile.in"
tar -tzf "${DIST_FILE}.tar.gz" | grep -Fx "${DIST_FILE}/VERSION"
tar -tzf "${DIST_FILE}.tar.gz" | grep -Fx "${DIST_FILE}/README.md"

- name: Upload source dist
uses: actions/upload-artifact@v4
with:
name: cunit-source-dist
path: ${{ needs.verify-version.outputs.dist_file }}.tar.gz
if-no-files-found: error

package:
name: Build release assets (UCRT64)
runs-on: windows-latest
needs: verify-version
needs:
- verify-version
- source-dist

defaults:
run:
Expand All @@ -80,16 +147,11 @@ jobs:
base-devel
git

- name: Create source tarball for PKGBUILD
env:
DIST_DIR: ${{ needs.verify-version.outputs.dist_dir }}
DIST_FILE: ${{ needs.verify-version.outputs.dist_file }}
working-directory: packaging/msys2
run: |
git -C ../.. archive \
--format=tar.gz \
--prefix="${DIST_DIR}/" \
HEAD > "${DIST_FILE}.tar.gz"
- name: Download source dist for PKGBUILD
uses: actions/download-artifact@v4
with:
name: cunit-source-dist
path: packaging/msys2

- name: Build package
working-directory: packaging/msys2
Expand All @@ -104,6 +166,39 @@ jobs:
packaging/msys2/*.tar.gz
if-no-files-found: error

test-source-dist-rocky8:
name: Test source dist (Rocky 8)
runs-on: ubuntu-latest
container: rockylinux:8
needs:
- verify-version
- source-dist

steps:
- name: Install build dependencies
run: dnf -y install gcc make diffutils findutils tar gzip

- name: Download source dist
uses: actions/download-artifact@v4
with:
name: cunit-source-dist
path: .

- name: Build and test source dist
env:
DIST_FILE: ${{ needs.verify-version.outputs.dist_file }}
run: |
tar -xzf "${DIST_FILE}.tar.gz"
mkdir build
cd build
"../${DIST_FILE}/configure" \
--prefix=/tmp/cunit-rocky8 \
--enable-debug \
--enable-test
make -j"$(nproc)"
./CUnit/Sources/Test/test_cunit | tee test_cunit.log
grep -q "Failures: 0" test_cunit.log

test-package:
name: Test installed release package (UCRT64)
runs-on: windows-latest
Expand Down Expand Up @@ -155,9 +250,14 @@ jobs:

publish-release:
name: Publish GitHub release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- verify-version
- source-dist
- test-source-dist-rocky8
- test-package

steps:
Expand All @@ -177,8 +277,9 @@ jobs:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
PKG_VERSION: ${{ needs.verify-version.outputs.pkg_version }}
RELEASE_TAG: ${{ needs.verify-version.outputs.release_tag }}
run: |
gh release create "${GITHUB_REF_NAME}" \
gh release create "${RELEASE_TAG}" \
--repo "${GH_REPO}" \
--verify-tag \
--generate-notes \
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ missing
*.lo
*.o
*.la
*.a
**/Makefile
**/.deps
**/.libs
doc/headers/*.h
config.log
CUnit.spec
config.status
cunit.pc
config.h
CUnit/Headers/CUnit.h
CUnit*Dump.xml
stamp-h1
CUnit/Sources/Test/test_cunit
4 changes: 2 additions & 2 deletions CUnit.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Summary: A unit testing framework for 'C'
Name: @PACKAGE@
Version: @VERSION@
Release: @RELEASE@
Source: http://www.sourceforge.net/projects/cunit/cunit-@VERSION@-@RELEASE@.tar.gz
Source: http://www.sourceforge.net/projects/cunit/cunit-@DIST_VERSION@.tar.gz
Group: Development/Tools
License: GPL
URL: http://cunit.sourceforge.net
Expand All @@ -15,7 +15,7 @@ headers, and documentation files.

%prep
echo "Preparing for Installation."
%setup -q -n cunit-@VERSION@-@RELEASE@
%setup -q -n cunit-@DIST_VERSION@

%build
echo "Preparing for Building."
Expand Down
8 changes: 8 additions & 0 deletions CUnit/Headers/CUnit.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@
#define CU_FAIL_FATAL(msg) \
{ CU_assertImplementation(CU_FALSE, __LINE__, ("CU_FAIL_FATAL(" #msg ")"), __FILE__, "", CU_TRUE); }

/** Skip the current test with a reason, and return from the test function. */
#define CU_SKIP(reason) \
{ CU_skipImplementation(__LINE__, __FILE__, (reason)); return; }

/** Skip the current test with a reason if the condition is true, and return from the test function. */
#define CU_SKIP_IF(value, reason) \
{ if (value) { CU_skipImplementation(__LINE__, __FILE__, (reason)); return; } }

/** Asserts that value is CU_TRUE.
* Reports failure with no other action.
*/
Expand Down
Loading
Loading