Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: tests: set GIT_DIR #145

Merged
merged 5 commits into from
Feb 18, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
run: make check

- name: Run tests
run: make tests
run: make tests GIT_CONFIG_GLOBAL=/dev/null
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ user-%:
$(MAKE) $* PREFIX=$$HOME/.local

test tests:
@$(MAKE) -C tests
@$(MAKE) -C tests GIT_DIR=$(CURDIR)/.git

check:
shellcheck cqfd
8 changes: 4 additions & 4 deletions cqfd
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ make_archive() {
done

# template the generated archive's filename
git_short=$(git rev-parse --short HEAD 2>/dev/null || true)
git_long=$(git rev-parse HEAD 2>/dev/null || true)
date_rfc3339=$(date +%Y-%m-%d || true)
date_unix=$(date +%s || true)
git_short=$(git rev-parse --short HEAD 2>/dev/null || echo unset)
git_long=$(git rev-parse HEAD 2>/dev/null || echo unset)
date_rfc3339=$(date +"%Y-%m-%d")
date_unix=$(date +%s)

# default name for the archive if not set
if [ -z "$release_archive" ]; then
Expand Down
92 changes: 87 additions & 5 deletions tests/06-cqfd_release
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,104 @@ rm -rf "${tmp_dir}"
################################################################################
# Now test adding an archive filename template to the config
################################################################################
jtest_prepare "build.archive can template filenames"
jtest_prepare "build.archive can template filenames (RFC3339 date)"

export CTEST=foobar
d3=$(date --rfc-3339='date')
echo 'archive=cqfd-%D3-$CTEST.tar.xz' >> .cqfdrc

# Generate the release archive
$cqfd release

if tar tf cqfd-$d3-foobar.tar.xz >/dev/null 2>&1; then
if $cqfd release && tar tf cqfd-$d3-foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-$d3-foobar.tar.xz

jtest_prepare "build.archive can template filenames (git short hash of last commit)"
sed -i -e '$ s!^archive=.*!archive=cqfd-%Gh-$CTEST.tar.xz!' .cqfdrc

if $cqfd release &&
ls -1 cqfd-*-foobar.tar.xz | grep -q "^cqfd-[[:xdigit:]]\{4,40\}-foobar.tar.xz$" &&
tar tf cqfd-*-foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-*-foobar.tar.xz

jtest_prepare "build.archive can template filenames (git long hash of last commit)"
sed -i -e '$ s!^archive=.*!archive=cqfd-%GH-$CTEST.tar.xz!' .cqfdrc

if $cqfd release &&
ls -1 cqfd-*-foobar.tar.xz | grep -q "^cqfd-[[:xdigit:]]\{40\}-foobar.tar.xz$" &&
tar tf cqfd-*-foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-*-foobar.tar.xz

jtest_prepare "build.archive can template filenames (Unix timestamp)"
sed -i -e '$ s!^archive=.*!archive=cqfd-%Du-$CTEST.tar.xz!' .cqfdrc

if $cqfd release &&
ls -1 cqfd-*-foobar.tar.xz | grep -q "^cqfd-[[:digit:]]\{1,20\}-foobar.tar.xz$" &&
tar tf cqfd-*-foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-*-foobar.tar.xz

jtest_prepare "build.archive can template filenames (current cqfd flavor name unset)"
sed -i -e '$ s!^archive=.*!archive=cqfd-%Cf-$CTEST.tar.xz!' .cqfdrc

if $cqfd release && tar tf cqfd--foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd--foobar.tar.xz

jtest_prepare "build.archive can template filenames (current cqfd flavor name set)"

if $cqfd -b foo release && tar tf cqfd-foo.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-foo.tar.xz

jtest_prepare "build.archive can template filenames (value of the project.org configuration key)"
sed -i -e '$ s!^archive=.*!archive=cqfd-%Po-$CTEST.tar.xz!' .cqfdrc

if $cqfd release && tar tf cqfd-cqfd-foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-cqfd-foobar.tar.xz

jtest_prepare "build.archive can template filenames (value of the project.name configuration key)"
sed -i -e '$ s!^archive=.*!archive=cqfd-%Pn-$CTEST.tar.xz!' .cqfdrc

if $cqfd release && tar tf cqfd-test-foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-test-foobar.tar.xz

jtest_prepare "build.archive can template filenames (litteral '%' sign)"
sed -i -e '$ s!^archive=.*!archive=cqfd-%%-$CTEST.tar.xz!' .cqfdrc

if $cqfd release && tar tf cqfd-%-foobar.tar.xz >/dev/null 2>&1; then
jtest_result pass
else
jtest_result fail
fi
rm -f cqfd-%-foobar.tar.xz

################################################################################
# Now test generation of .tar.gz archives
################################################################################
Expand Down
Loading