forked from zunit-zsh/zunit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build zunit via makefile (#12)
* fix(build): remove build.zsh * docs(readme): zinit install --------- Signed-off-by: Vladislav Doster <[email protected]>
- Loading branch information
1 parent
7c4cc63
commit b15c870
Showing
7 changed files
with
262 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# vim: ft=make sw=4 ts=4 noet! | ||
|
||
PREFIX ?= /usr/local | ||
SHELL ?= sh | ||
|
||
CRAM_OPTS ?= -v | ||
|
||
PROJECT ?= $(CURDIR) | ||
BIN ?= ${PROJECT}/bin | ||
DOCS ?= ${PROJECT}/docs | ||
SRC ?= ${PROJECT}/src | ||
TESTS ?= ${PROJECT}/tests | ||
|
||
ZSH_VERSION ?= zsh-5.8 | ||
CONTAINER_ROOT ?= /zunit | ||
USE_CONTAINER ?= docker | ||
CONTAINER_IMAGE ?= desyncr/zsh-docker- | ||
|
||
PROG ?= ${BIN}/zunit | ||
SRC ?= ${SRC} | ||
GLOB ?= | ||
|
||
LIB = $(filter-out ${SRC}/zunit.zsh,$(wildcard ${SRC}/*.zsh)) | ||
COMMANDS = $(sort $(wildcard ${SRC}/commands/*.zsh)) | ||
REPORTS = $(sort $(wildcard ${SRC}/reports/*.zsh)) | ||
GLOB += ${LIB} ${REPORTS} ${COMMANDS} ${SRC}/zunit.zsh | ||
|
||
VERSION ?= develop | ||
VERSION_FILE = ${PROJECT}/VERSION | ||
|
||
BANNER_SEP = $(shell printf '%*s' 70 | tr ' ' '\#') | ||
BANNER_TEXT = This file was autogenerated by \`make\`. Do not edit it directly! | ||
BANNER = ${BANNER_SEP}\n\# ${BANNER_TEXT}\n${BANNER_SEP}\n | ||
HEADER_TEXT =\ | ||
\#!/usr/bin/env zsh\n\ | ||
\# Zunit: A unit test framework for zsh\n\ | ||
\# License: MIT License\n | ||
define ised | ||
sed $(1) $(2) > "$(2).1" | ||
mv "$(2).1" "$(2)" | ||
endef | ||
define isede | ||
sed -E $(1) $(2) > "$(2).1" | ||
mv "$(2).1" "$(2)" | ||
endef | ||
.PHONY: all build clean install itests tests uninstall | ||
all: build | ||
release: | ||
git checkout develop | ||
git checkout -b release/${VERSION} | ||
${MAKE} build tests | ||
${EDITOR} CHANGELOG.md | ||
git add CHANGELOG.md README.mkd ${VERSION_FILE} | ||
git commit -S -m "Update changelog for ${VERSION}" | ||
git add ${PROG} | ||
git commit -S -m "Build release ${VERSION}" | ||
publish: | ||
git push origin release/${VERSION} | ||
deploy: | ||
git checkout develop | ||
git tag -m "Build release ${VERSION}" -s ${VERSION} | ||
git archive --output=${VERSION}.tar.gz --prefix=zunit-$$(echo ${VERSION}|sed s/v//)/ ${VERSION} | ||
zcat ${VERSION}.tar.gz | gpg --armor --detach-sign >${VERSION}.tar.gz.sign | ||
zcat ${VERSION}.tar.gz | gpg --verify ${VERSION}.tar.gz.sign - | ||
git push upstream ${VERSION} | ||
.container: | ||
ifeq (${USE_CONTAINER}, docker) | ||
@docker run --rm --privileged=true -it -v ${PROJECT}:/zunit ${CONTAINER_IMAGE}${ZSH_VERSION} $(shell echo "${COMMAND}" | sed "s|${PROJECT}|${CONTAINER_ROOT}|g") | ||
else ifeq (${USE_CONTAINER}, no) | ||
${COMMAND} | ||
endif | ||
docs: | ||
mkdir ${DOCS}; cd ${DOCS}; zsh -dfilc "zsd -v --scomm --cignore '(\#*FUNCTION:[[:space:]][\:\∞\.\+\@\-a-zA-Z0-9]*[\[]*|}[[:space:]]\#[[:space:]][\]]*)' ${GLOB}" | ||
info: | ||
@${MAKE} .container COMMAND="sh -c 'cat ${PROJECT}/VERSION; zsh --version; git --version; env'" | ||
tests: | ||
@${make} .container command="sh -c 'zdotdir=${tests} zunit=${project} cram ${cram_opts} --shell=zsh ${test}'" | ||
tests: | ||
${PROG} run | ||
install: | ||
install -cv -m755 ${PROG} ${PREFIX}/bin/zunit | ||
uninstall: | ||
rm -f ${PREFIX}/bin/zunit | ||
clean: | ||
rm -rf ${BIN} Makefile | ||
install-deps: | ||
sudo pip install cram=='0.6.*' | ||
build: | ||
@echo Building Zunit... | ||
@mkdir -p ${BIN} | ||
@printf "${HEADER_TEXT}" > ${PROG} | ||
@echo "${BANNER}" >> ${PROG} | ||
@for src in ${GLOB}; do echo "----> $$src"; cat "$$src" | grep -v -e '#\svim.*' -e '^(\s*#.*|\s*)\$$' >> ${PROG}; done | ||
@$(call ised,"s/{{ZUNIT_REVISION}}/$$(git log -n1 --format=%h -- src)/",${PROG}) | ||
@$(call ised,"s/{{ZUNIT_REVISION_DATE}}/$$(git log -n1 --format='%ai' -- src)/",${PROG}) | ||
@$(call ised,"s/{{ZUNIT_VERSION}}/$$(cat ${VERSION_FILE})/",${PROG}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/zsh | ||
# vim: ft=zsh sw=4 ts=4 noet! | ||
target=Makefile | ||
arguments="$@" | ||
typeset -A opts; | ||
opts=(prefix /usr/local) | ||
|
||
if [[ $1 == "--help" || $1 == "-h" ]]; then | ||
cat >&1 <<EOH | ||
Usage: | ||
./configure --prefix[=[PATH]] | ||
Available options: | ||
- prefix - Set install prefix | ||
All options are enabled by default. | ||
Example: | ||
# Disable lock, parallel, cache and defer | ||
./configure --disable-extensions | ||
# Disable completion | ||
./configure --disable-completion | ||
# Enable debug | ||
./configure --with-debug | ||
EOH | ||
exit 0 | ||
fi | ||
|
||
|
||
while [[ $# -gt 0 ]]; do | ||
argkey="${1%\=*}" | ||
key="${argkey//--/}" | ||
if [[ $1 = *=* ]]; then | ||
value="${1#*=}" | ||
else | ||
value=$opts[$key] | ||
fi | ||
|
||
if [[ $opts[$key] != "" ]]; then | ||
opts[$key]=$value | ||
else | ||
printf "Invalid argument: %s (%s)\n" $key $1 >&2 | ||
exit 1 | ||
fi | ||
|
||
shift | ||
|
||
done | ||
|
||
BANNER_SEP=$(printf '%*s' 70 | tr ' ' '\#') | ||
|
||
cat > $target <<EOM | ||
${BANNER_SEP} | ||
# This file was autogenerated by 'configure'. Do not edit it directly! | ||
# Invocation was: $0 $arguments | ||
${BANNER_SEP} | ||
EOM | ||
|
||
{ | ||
for config in ${(k)opts}; do | ||
echo "${${config:u}//-/_}=${opts[$config]}" | ||
done | ||
|
||
echo ${BANNER_SEP} | ||
cat Makefile.in | ||
} >> $target |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,58 @@ | ||
######################################## | ||
# Functions for handling TAP reporting # | ||
######################################## | ||
# vim: ft=zsh sw=4 ts=4 et foldmarker=[[[,]]] foldmethod=marker | ||
|
||
### | ||
# Output a TAP compatible success message | ||
### | ||
function _zunit_tap_success() { | ||
echo "ok ${total} - ${name}" | ||
} | ||
|
||
### | ||
# Output a TAP compatible failure message | ||
### | ||
function _zunit_tap_failure() { | ||
# FUNCTION: _zunit_tap_error [[[ | ||
# Output a TAP compatible error message | ||
function _zunit_tap_error() { | ||
local message="$@" | ||
|
||
echo "not ok ${total} - Failure: ${name}" | ||
echo "not ok ${total} - Error: ${name}" | ||
echo " ---" | ||
echo " message: ${message}" | ||
echo " severity: fail" | ||
echo " ..." | ||
|
||
[[ -n $fail_fast ]] && echo "Bail out!" | ||
} | ||
|
||
### | ||
# Output a TAP compatible error message | ||
### | ||
function _zunit_tap_error() { | ||
} # ]]] | ||
# FUNCTION: _zunit_tap_failure [[[ | ||
# Output a TAP compatible failure message | ||
function _zunit_tap_failure() { | ||
local message="$@" | ||
|
||
echo "not ok ${total} - Error: ${name}" | ||
echo "not ok ${total} - Failure: ${name}" | ||
echo " ---" | ||
echo " message: ${message}" | ||
echo " severity: fail" | ||
echo " ..." | ||
|
||
[[ -n $fail_fast ]] && echo "Bail out!" | ||
} | ||
|
||
### | ||
# Output a TAP compatible warning message | ||
### | ||
function _zunit_tap_warn() { | ||
} # ]]] | ||
# FUNCTION: _zunit_tap_skip [[[ | ||
# Output a TAP compatible skipped test message | ||
function _zunit_tap_skip() { | ||
local message="$@" | ||
|
||
echo "ok ${total} - Warning: ${name}" | ||
echo "ok ${total} - # SKIP ${name}" | ||
echo " ---" | ||
echo " message: ${message}" | ||
echo " severity: comment" | ||
echo " ..." | ||
} | ||
|
||
### | ||
# Output a TAP compatible skipped test message | ||
### | ||
function _zunit_tap_skip() { | ||
} # ]]] | ||
# FUNCTION: _zunit_tap_success [[[ | ||
# Output a TAP compatible success message | ||
function _zunit_tap_success() { | ||
echo "ok ${total} - ${name}" | ||
} # ]]] | ||
# FUNCTION: _zunit_tap_warn [[[ | ||
# Output a TAP compatible warning message | ||
function _zunit_tap_warn() { | ||
local message="$@" | ||
|
||
echo "ok ${total} - # SKIP ${name}" | ||
echo "ok ${total} - Warning: ${name}" | ||
echo " ---" | ||
echo " message: ${message}" | ||
echo " severity: comment" | ||
echo " ..." | ||
} | ||
} # ]]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters