source: trunk/base/tests/Makefile @ 107523

Last change on this file since 107523 was 96400, checked in by cal@…, 8 years ago

base: add tests for statefile format 1,2 and future unhandled statefile formats

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1include ../Mk/macports.autoconf.mk
2
3TESTS?=checksums-1 svn-and-patchsites envvariables site-tags trace universal universal-2 xcodeversion dependencies-c dependencies-d dependencies-e case-insensitive-deactivate variants statefile-version1 statefile-version1-outdated statefile-version2 statefile-version2-outdated statefile-version2-invalid statefile-unknown-version
4
5PWD=$(shell pwd)
6
7.PHONY: all clean install test 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/registry/
19        mkdir -p /tmp/macports-tests/opt/local/var/macports/build/
20        ln -s $(datadir)/macports /tmp/macports-tests/opt/local/share/
21        ln -s $(PWD)/test /tmp/macports-tests/ports/
22        cp sources.conf /tmp/macports-tests/opt/local/etc/macports/
23
24/tmp/macports-tests/ports/PortIndex: /tmp/macports-tests/opt/local/etc/macports/sources.conf PortIndex
25        cp PortIndex PortIndex.quick /tmp/macports-tests/ports/
26
27PortIndex:
28        $(bindir)/portindex
29
30clean::
31        rm -rf /tmp/macports-tests/
32        rm -f PortIndex 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        @num=0; \
46        success=0; \
47        for testname in $(TESTS); do\
48                subdir=test/$$testname; \
49                echo ===\> test ${DIRPRFX}$$subdir; \
50                if [ -e $$subdir/Makefile ]; then \
51                        ( cd $$subdir && \
52                                $(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ PORTSRC=$(PWD)/test-macports.conf test) && \
53                        success=$$(( success + 1 )); \
54                else \
55                        ( cd $$subdir && \
56                                PORTSRC=$(PWD)/test-macports.conf $(bindir)/port clean > /dev/null && \
57                                PORTSRC=$(PWD)/test-macports.conf $(bindir)/port test > output 2>&1 \
58                                        || ([ -e error_expected ] || (cat output; exit 1)) && \
59                        sed -e "s|${PWD}|PWD|g" < output > output.sed && \
60                        diff -u master output.sed 2>&1 | tee difference && \
61                        if [ -s difference ]; then \
62                                exit 1; \
63                        else \
64                                rm -f difference output.sed; \
65                        fi) && \
66                        success=$$(( success + 1 )); \
67                        if [ -n "`PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -q echo installed`" ]; then \
68                            PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f clean --all installed > /dev/null && \
69                            PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f uninstall installed > /dev/null; \
70                        fi; \
71                fi; \
72                num=$$(( num + 1 )); \
73        done; \
74        echo ===\> $$success of $$num tests passed.
75        @rm -rf /tmp/macports-tests/
76        @rm -f PortIndex PortIndex.quick
77
78# Run specific test
79# Prepend the directory name with "test-" and use it as target
80# For example: make test-checksums-1
81test-%:
82        $(MAKE) TESTS="$(@:test-%=%)" test
83
84install::
85
86distclean:: clean
Note: See TracBrowser for help on using the repository browser.