mirror of
https://github.com/serokell/xrefcheck.git
synced 2024-10-05 18:07:35 +03:00
[#134] Add makefile
Problem: Most of our projects have a makefile for running common tasks. We should add one to xrefcheck as well. Solution: Add makefile.
This commit is contained in:
parent
54aa5415bf
commit
1543744a0c
67
Makefile
Normal file
67
Makefile
Normal file
@ -0,0 +1,67 @@
|
||||
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
.PHONY: xrefcheck test lint clean bats all
|
||||
|
||||
# Build target from the common utility Makefile
|
||||
MAKEU = $(MAKE) -C make/
|
||||
|
||||
MAKE_PACKAGE = $(MAKEU) PACKAGE=xrefcheck
|
||||
|
||||
xrefcheck:
|
||||
$(MAKE_PACKAGE) dev
|
||||
|
||||
# Runs all tests.
|
||||
# Usage:
|
||||
# * make test
|
||||
# * make test BATSFILTER='test name' TEST_ARGUMENTS='--match \"test name\"'
|
||||
test:
|
||||
make test-unit
|
||||
make test-ftp
|
||||
make bats
|
||||
|
||||
test-dumb-term:
|
||||
$(MAKE_PACKAGE) test-dumb-term
|
||||
|
||||
test-hide-successes:
|
||||
$(MAKE_PACKAGE) test-hide-successes
|
||||
|
||||
clean:
|
||||
$(MAKE_PACKAGE) clean
|
||||
|
||||
lint:
|
||||
hlint .
|
||||
|
||||
####################################
|
||||
# Individual test suites
|
||||
|
||||
test-unit:
|
||||
$(MAKEU) test PACKAGE="xrefcheck:test:xrefcheck-tests"
|
||||
|
||||
test-ftp:
|
||||
vsftpd \
|
||||
-orun_as_launching_user=yes \
|
||||
-olisten_port=2221 \
|
||||
-olisten=yes \
|
||||
-oftp_username=$(shell whoami) \
|
||||
-oanon_root=./ftp-tests/ftp_root \
|
||||
-opasv_min_port=2222 \
|
||||
-ohide_file='{.*}' \
|
||||
-odeny_file='{.*}' \
|
||||
-oseccomp_sandbox=no \
|
||||
-olog_ftp_protocol=yes \
|
||||
-oxferlog_enable=yes \
|
||||
-ovsftpd_log_file=/tmp/vsftpd.log &
|
||||
|
||||
$(MAKEU) test PACKAGE="xrefcheck:test:ftp-tests" \
|
||||
TEST_ARGUMENTS="--ftp-host ftp://127.0.0.1:2221"
|
||||
|
||||
# Usage:
|
||||
# * make bats
|
||||
# * make bats BATSFILTER="test name"
|
||||
# * make bats BATSFILTER="regex to match several tests"
|
||||
bats:
|
||||
stack install --fast xrefcheck:exe:xrefcheck
|
||||
git submodule update --init --recursive
|
||||
bats ./tests/golden/** -f $(if $(BATSFILTER),"$(BATSFILTER)",".*")
|
44
make/Makefile
Normal file
44
make/Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
# Defines utilities for other Makefiles
|
||||
|
||||
.PHONY: dev test test-dumb-term test-hide-successes clean
|
||||
|
||||
# Options for development
|
||||
STACK_DEV_OPTIONS = --fast --ghc-options -Wwarn --file-watch
|
||||
# Options to build more stuff (tests and benchmarks)
|
||||
STACK_BUILD_MORE_OPTIONS = --test --bench --no-run-tests --no-run-benchmarks
|
||||
# Options for tests
|
||||
STACK_DEV_TEST_OPTIONS = --fast
|
||||
# Addtional (specified by user) options passed to test executable
|
||||
TEST_ARGUMENTS ?= ""
|
||||
# Packages to apply the command (build, test, e.t.c) for.
|
||||
PACKAGE ?= non-defined-package
|
||||
|
||||
define call_test
|
||||
stack test $(PACKAGE) --test-arguments "$(TEST_ARGUMENTS) $1" $2
|
||||
endef
|
||||
|
||||
# Build everything (including tests and benchmarks) with development options.
|
||||
dev:
|
||||
stack build $(STACK_DEV_OPTIONS) $(STACK_BUILD_MORE_OPTIONS) $(PACKAGE)
|
||||
|
||||
# Run tests in all packages which have them.
|
||||
test:
|
||||
$(call call_test,"",$(STACK_DEV_TEST_OPTIONS))
|
||||
|
||||
# Like 'test' command, but enforces dumb terminal which may be useful to
|
||||
# workardoung some issues with `tasty`.
|
||||
# Primarily this one: https://github.com/feuerbach/tasty/issues/152
|
||||
test-dumb-term:
|
||||
TERM=dumb $(call call_test,"",$(STACK_DEV_TEST_OPTIONS))
|
||||
|
||||
# Run tests with `--hide-successes` option. It forces dumb terminal,
|
||||
# because otherwise this option is likely to work incorrectly.
|
||||
test-hide-successes:
|
||||
TERM=dumb $(call call_test,"--hide-successes",$(STACK_DEV_TEST_OPTIONS))
|
||||
|
||||
clean:
|
||||
stack clean $(PACKAGE)
|
Loading…
Reference in New Issue
Block a user