Skip to content

Commit

Permalink
Merge pull request #143 from serokell/Sereja313/#134-add-makefile
Browse files Browse the repository at this point in the history
[#134] Add makefile
  • Loading branch information
Sereja313 authored Sep 27, 2022
2 parents 54aa541 + 1543744 commit 06c96e2
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
67 changes: 67 additions & 0 deletions Makefile
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)",".*")
44 changes: 44 additions & 0 deletions make/Makefile
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)

0 comments on commit 06c96e2

Please sign in to comment.