-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#134] Add makefile
- Loading branch information
Showing
2 changed files
with
111 additions
and
0 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,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)",".*") |
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,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) |