source: trunk/base/tests/Makefile @ 50573

Last change on this file since 50573 was 47340, checked in by raimue@…, 11 years ago

tests/Makefile:
Let clean remove everything created during a test run

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1include ../Mk/macports.autoconf.mk
2
3TESTS?=checksums-1 cvs-and-patchsites envvariables site-tags trace universal universal-2 xcodeversion dependencies-c dependencies-d dependencies-e case-insensitive-deactivate variants
4
5PWD=$(shell pwd)
6
7.PHONY: test clean PortIndex
8
9all:
10
11/tmp/macports-tests/opt/local/etc/macports/sources.conf: sources.conf
12        @echo setting up test installation
13        rm -rf /tmp/macports-tests/
14        mkdir -p /tmp/macports-tests/ports
15        mkdir -p /tmp/macports-tests/opt/local/etc/macports/
16        mkdir -p /tmp/macports-tests/opt/local/share/
17        mkdir -p /tmp/macports-tests/opt/local/var/macports/receipts/
18        mkdir -p /tmp/macports-tests/opt/local/var/macports/build/
19        ln -s $(datadir)/macports /tmp/macports-tests/opt/local/share/
20        ln -s $(PWD)/test /tmp/macports-tests/ports/
21        cp sources.conf /tmp/macports-tests/opt/local/etc/macports/
22
23/tmp/macports-tests/ports/PortIndex: /tmp/macports-tests/opt/local/etc/macports/sources.conf PortIndex
24        cp PortIndex /tmp/macports-tests/ports/PortIndex
25
26PortIndex:
27        $(bindir)/portindex
28
29clean:
30        rm -rf /tmp/macports-tests/
31        rm -f PortIndex
32        rm -f PortIndex.quick
33        for testname in $(TESTS); do \
34                rm -f test/$$testname/{output,output.sed,difference,work}; \
35        done
36
37$(bindir)/port:
38        @echo "Please install MacPorts before running these tests"
39        @exit 1
40
41# Run all tests
42# Use TESTS to choose which tests to run
43# For example: make test TESTS="checkums-1 universal"
44test: clean /tmp/macports-tests/ports/PortIndex /tmp/macports-tests/opt/local/etc/macports/sources.conf
45        @for testname in $(TESTS); do\
46            subdir=test/$$testname; \
47                echo ===\> test ${DIRPRFX}$$subdir; \
48                if [ -e ${DIRPRFX}$$subdir/Makefile ]; then \
49                        ( cd $$subdir && \
50                                $(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ PORTSRC=$(PWD)/test-macports.conf test) || exit 1; \
51                else \
52                        ( cd $$subdir && \
53                                PORTSRC=$(PWD)/test-macports.conf $(bindir)/port clean > /dev/null && \
54                                PORTSRC=$(PWD)/test-macports.conf $(bindir)/port test > output 2>&1 \
55                                        || (cat output; exit 1) && \
56                        sed -e "s|${PWD}|PWD|g" < output > output.sed && \
57                        diff output.sed master 2>&1 | tee difference && \
58                        if [ -s difference ]; then \
59                                exit 1; \
60                        else \
61                                rm -f difference output.sed; \
62                        fi) \
63                fi || exit 1; \
64        done
65        @rm -rf /tmp/macports-tests/
66        @rm -f PortIndex
67
68# Run specific test
69# Prepend the directory name with "test-" and use it as target
70# For example: make test-checksums-1
71test-%:
72        $(MAKE) TESTS="$(@:test-%=%)" test
73
74install:
75
76distclean: clean
Note: See TracBrowser for help on using the repository browser.