From 7383c4984e5bc3486f6c575f3215d7f43d8a2611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 13 Oct 2022 12:39:17 +0300 Subject: [PATCH] ci/test: add tests for exact expected artifacts. Cache reuse in zig is currently quite fragile (we are using a forked version with github.com/ziglang/zig/issues/13051), so ensure that it does not regress when zig SDK upgrades. --- ci/test | 17 +++++++++++++++-- ci/testdata/want_cache | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 ci/testdata/want_cache diff --git a/ci/test b/ci/test index dd96eac..6b2895c 100755 --- a/ci/test +++ b/ci/test @@ -1,2 +1,15 @@ -#!/bin/sh -exec bazel test "$@" ... +#!/usr/bin/env bash +set -euo pipefail + +bazel test "$@" ... + +# /tmp/bazel-zig-cc should be empty for the test below to be valid. +# This test ensures that github.com/ziglang/zig/issues/13050 does not +# regress from a "very high"-level perspective. +find /tmp/bazel-zig-cc -name mutex_destructor.o -execdir file {} \; | \ + sort | uniq -c | sort -rn > /tmp/got_cache + +diff -u ci/testdata/want_cache /tmp/got_cache || { + >&2 echo "ERROR: unexpected artifacts." + >&2 echo "Was /tmp/bazel-zig-cc empty before the test?" +} diff --git a/ci/testdata/want_cache b/ci/testdata/want_cache new file mode 100644 index 0000000..0a124e2 --- /dev/null +++ b/ci/testdata/want_cache @@ -0,0 +1,3 @@ + 5 ./mutex_destructor.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped + 3 ./mutex_destructor.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped + 1 ./mutex_destructor.o: Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>