tests: use IO.pipe directly
[yahns.git] / GNUmakefile
blob2cd90790bec08b74c55daf9a8b5aac4f250b5452
1 # Copyright (C) 2013-2016 all contributors <yahns-public@yhbt.net>
2 # License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
3 all::
4 pkg = yahns
5 rubybin := $(shell which ruby)
6 RUBY = $(rubybin)
7 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8 @./GIT-VERSION-GEN
9 -include GIT-VERSION-FILE
10 lib := lib
12 ifeq ($(RUBY_TEST_OPTS),)
13 ifeq ($(V),1)
14 RUBY_TEST_OPTS := -v
15 endif
16 endif
18 all:: test
19 test_units := $(wildcard test/test_*.rb)
20 test: $(test_units)
21 $(test_units):
22 $(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
24 test-mt: export N = $(shell nproc 2>/dev/null || echo 4)
25 test-mt: t := $(addprefix -r./,$(test_units))
26 test-mt:
27 $(RUBY) -I $(lib) $(t) -erubyv -- $(RUBY_TEST_OPTS)
29 check-warnings:
30 @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
31 do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
33 check: test
34 coverage: export COVERAGE=1
35 coverage:
36 > coverage.dump
37 $(MAKE) check
38 $(RUBY) ./test/covshow.rb
40 coverage-mt: export COVERAGE=1
41 coverage-mt:
42 > coverage.dump
43 $(MAKE) test-mt
44 $(RUBY) ./test/covshow.rb
46 pkggem := pkg/$(pkg)-$(VERSION).gem
47 pkgtgz := pkg/$(pkg)-$(VERSION).tar.gz
49 fix-perms:
50 git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
51 git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
53 gem: $(pkggem)
55 install-gem: $(pkggem)
56 gem install --local $(CURDIR)/$<
58 $(pkggem): .gem-manifest
59 VERSION=$(VERSION) gem build $(pkg).gemspec
60 mkdir -p pkg
61 mv $(@F) $@
63 pkg_extra := GIT-VERSION-FILE lib/yahns/version.rb NEWS
64 NEWS:
65 rake -s $@
67 gem-man:
68 $(MAKE) -C Documentation/ gem-man
69 tgz-man:
70 $(MAKE) -C Documentation/ install-man mandir=$(CURDIR)/man
71 .PHONY: tgz-man gem-man
73 .gem-manifest: .manifest gem-man
74 (ls man/*.?; cat .manifest) | LC_ALL=C sort > $@+
75 cmp $@+ $@ || mv $@+ $@; rm -f $@+
76 .tgz-manifest: .manifest
77 (ls man/*/*; cat .manifest) | LC_ALL=C sort > $@+
78 cmp $@+ $@ || mv $@+ $@; rm -f $@+
79 .manifest: NEWS fix-perms
80 rm -rf man
81 (git ls-files; \
82 for i in $(pkg_extra); do echo $$i; done) | \
83 LC_ALL=C sort > $@+
84 cmp $@+ $@ || mv $@+ $@; rm -f $@+
85 $(pkgtgz): distdir = pkg/$(pkg)-$(VERSION)
86 $(pkgtgz): .tgz-manifest
87 @test -n "$(distdir)"
88 $(RM) -r $(distdir)
89 mkdir -p $(distdir)
90 tar cf - $$(cat .tgz-manifest) | (cd $(distdir) && tar xf -)
91 cd pkg && tar cf - $(pkg)-$(VERSION) | gzip -9 > $(@F)+
92 mv $@+ $@
94 package: $(pkgtgz) $(pkggem)
96 .PHONY: all .FORCE-GIT-VERSION-FILE test $(test_units) NEWS
97 .PHONY: check-warnings fix-perms