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
RevLine 
[26177]1include ../Mk/macports.autoconf.mk
[13743]2
[96400]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
[13743]4
[37264]5PWD=$(shell pwd)
6
[71039]7.PHONY: all clean install test PortIndex
[13743]8
[71039]9all::
[13743]10
[26177]11/tmp/macports-tests/opt/local/etc/macports/sources.conf: sources.conf
[13743]12        @echo setting up test installation
[23549]13        rm -rf /tmp/macports-tests/
[26177]14        mkdir -p /tmp/macports-tests/ports
15        mkdir -p /tmp/macports-tests/opt/local/etc/macports/
[23549]16        mkdir -p /tmp/macports-tests/opt/local/share/
[26177]17        mkdir -p /tmp/macports-tests/opt/local/var/macports/receipts/
[78036]18        mkdir -p /tmp/macports-tests/opt/local/var/macports/registry/
[26177]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/
[13743]23
[26177]24/tmp/macports-tests/ports/PortIndex: /tmp/macports-tests/opt/local/etc/macports/sources.conf PortIndex
[59676]25        cp PortIndex PortIndex.quick /tmp/macports-tests/ports/
[23701]26
27PortIndex:
[47339]28        $(bindir)/portindex
[23701]29
[71039]30clean::
[23549]31        rm -rf /tmp/macports-tests/
[59676]32        rm -f PortIndex PortIndex.quick
[47340]33        for testname in $(TESTS); do \
34                rm -f test/$$testname/{output,output.sed,difference,work}; \
35        done
[13743]36
37$(bindir)/port:
[26177]38        @echo "Please install MacPorts before running these tests"
[13743]39        @exit 1
[26177]40
[47324]41# Run all tests
42# Use TESTS to choose which tests to run
43# For example: make test TESTS="checkums-1 universal"
[71039]44test:: clean /tmp/macports-tests/ports/PortIndex /tmp/macports-tests/opt/local/etc/macports/sources.conf
[71045]45        @num=0; \
46        success=0; \
47        for testname in $(TESTS); do\
[71044]48                subdir=test/$$testname; \
[13743]49                echo ===\> test ${DIRPRFX}$$subdir; \
[79489]50                if [ -e $$subdir/Makefile ]; then \
[13743]51                        ( cd $$subdir && \
[71045]52                                $(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ PORTSRC=$(PWD)/test-macports.conf test) && \
53                        success=$$(( success + 1 )); \
[13743]54                else \
55                        ( cd $$subdir && \
[37265]56                                PORTSRC=$(PWD)/test-macports.conf $(bindir)/port clean > /dev/null && \
57                                PORTSRC=$(PWD)/test-macports.conf $(bindir)/port test > output 2>&1 \
[59679]58                                        || ([ -e error_expected ] || (cat output; exit 1)) && \
[18709]59                        sed -e "s|${PWD}|PWD|g" < output > output.sed && \
[71041]60                        diff -u master output.sed 2>&1 | tee difference && \
[13743]61                        if [ -s difference ]; then \
62                                exit 1; \
63                        else \
[18721]64                                rm -f difference output.sed; \
[71045]65                        fi) && \
66                        success=$$(( success + 1 )); \
[92404]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; \
[71045]71                fi; \
72                num=$$(( num + 1 )); \
73        done; \
74        echo ===\> $$success of $$num tests passed.
[23549]75        @rm -rf /tmp/macports-tests/
[59676]76        @rm -f PortIndex PortIndex.quick
[13744]77
[47324]78# Run specific test
79# Prepend the directory name with "test-" and use it as target
80# For example: make test-checksums-1
[47321]81test-%:
82        $(MAKE) TESTS="$(@:test-%=%)" test
83
[71039]84install::
[13891]85
[71039]86distclean:: clean
Note: See TracBrowser for help on using the repository browser.