[107862] branches/gsoc13-tests/tests

marius at macports.org marius at macports.org
Sun Jul 7 15:16:17 PDT 2013


Revision: 107862
          https://trac.macports.org/changeset/107862
Author:   marius at macports.org
Date:     2013-07-07 15:16:17 -0700 (Sun, 07 Jul 2013)
Log Message:
-----------
Added run all tests option.

Added Paths:
-----------
    branches/gsoc13-tests/tests/test.tcl

Removed Paths:
-------------
    branches/gsoc13-tests/tests/Makefile

Deleted: branches/gsoc13-tests/tests/Makefile
===================================================================
--- branches/gsoc13-tests/tests/Makefile	2013-07-07 21:00:00 UTC (rev 107861)
+++ branches/gsoc13-tests/tests/Makefile	2013-07-07 22:16:17 UTC (rev 107862)
@@ -1,86 +0,0 @@
-include ../Mk/macports.autoconf.mk
-
-TESTS?=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
-
-PWD=$(shell pwd)
-
-.PHONY: all clean install test PortIndex
-
-all::
-
-/tmp/macports-tests/opt/local/etc/macports/sources.conf: sources.conf
-	@echo setting up test installation
-	rm -rf /tmp/macports-tests/
-	mkdir -p /tmp/macports-tests/ports
-	mkdir -p /tmp/macports-tests/opt/local/etc/macports/
-	mkdir -p /tmp/macports-tests/opt/local/share/
-	mkdir -p /tmp/macports-tests/opt/local/var/macports/receipts/
-	mkdir -p /tmp/macports-tests/opt/local/var/macports/registry/
-	mkdir -p /tmp/macports-tests/opt/local/var/macports/build/
-	ln -s $(datadir)/macports /tmp/macports-tests/opt/local/share/
-	ln -s $(PWD)/test /tmp/macports-tests/ports/
-	cp sources.conf /tmp/macports-tests/opt/local/etc/macports/
-
-/tmp/macports-tests/ports/PortIndex: /tmp/macports-tests/opt/local/etc/macports/sources.conf PortIndex
-	cp PortIndex PortIndex.quick /tmp/macports-tests/ports/
-
-PortIndex:
-	$(bindir)/portindex
-
-clean::
-	rm -rf /tmp/macports-tests/
-	rm -f PortIndex PortIndex.quick
-	for testname in $(TESTS); do \
-		rm -f test/$$testname/{output,output.sed,difference,work}; \
-	done
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running these tests"
-	@exit 1
-
-# Run all tests
-# Use TESTS to choose which tests to run
-# For example: make test TESTS="checkums-1 universal"
-test:: clean /tmp/macports-tests/ports/PortIndex /tmp/macports-tests/opt/local/etc/macports/sources.conf
-	@num=0; \
-	success=0; \
-	for testname in $(TESTS); do\
-		subdir=test/$$testname; \
-		echo ===\> test ${DIRPRFX}$$subdir; \
-		if [ -e $$subdir/Makefile ]; then \
-			( cd $$subdir && \
-				$(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ PORTSRC=$(PWD)/test-macports.conf test) && \
-			success=$$(( success + 1 )); \
-		else \
-			( cd $$subdir && \
-				PORTSRC=$(PWD)/test-macports.conf $(bindir)/port clean > /dev/null && \
-				PORTSRC=$(PWD)/test-macports.conf $(bindir)/port test > output 2>&1 \
-					|| ([ -e error_expected ] || (cat output; exit 1)) && \
-			sed -e "s|${PWD}|PWD|g" < output > output.sed && \
-			diff -u master output.sed 2>&1 | tee difference && \
-			if [ -s difference ]; then \
-				exit 1; \
-			else \
-				rm -f difference output.sed; \
-			fi) && \
-			success=$$(( success + 1 )); \
-			if [ -n "`PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -q echo installed`" ]; then \
-			    PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f clean --all installed > /dev/null && \
-			    PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f uninstall installed > /dev/null; \
-			fi; \
-		fi; \
-		num=$$(( num + 1 )); \
-	done; \
-	echo ===\> $$success of $$num tests passed.
-	@rm -rf /tmp/macports-tests/
-	@rm -f PortIndex PortIndex.quick
-
-# Run specific test
-# Prepend the directory name with "test-" and use it as target
-# For example: make test-checksums-1
-test-%:
-	$(MAKE) TESTS="$(@:test-%=%)" test
-
-install::
-
-distclean:: clean

Added: branches/gsoc13-tests/tests/test.tcl
===================================================================
--- branches/gsoc13-tests/tests/test.tcl	                        (rev 0)
+++ branches/gsoc13-tests/tests/test.tcl	2013-07-07 22:16:17 UTC (rev 107862)
@@ -0,0 +1,79 @@
+set test_suite {
+    case-insensitive-deactivate
+    checksums-1
+    dependencies-a
+    dependencies-b
+    dependencies-c
+    dependencies-d
+    dependencies-e
+    envvariables
+    site-tags
+    statefile-unknown-version
+    statefile-version1
+    statefile-version1-outdated
+    statefile-version2
+    statefile-version2-invalid
+    statefile-version2-outdated
+    svn-and-patchsites
+    universal
+    variants
+    xcodeversion
+}
+set arguments ""
+set test_name ""
+
+proc print_help {arg} {
+    if { $arg == "tests" } {
+        puts "test list"
+    } else {
+        puts "help message"
+    }
+}
+
+# Process args
+foreach arg $argv {
+    if { $arg == "-h" || $arg == "-help" } {
+        print_help
+        exit 0
+    } elseif { $arg == "-debug" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set level [lindex $argv $index]
+        if { $level >= 0 && $level <= 5 } {
+            append arguments "-debug " $level
+        } else {
+            puts "Invalid debug level."
+            exit 1
+        }
+    } elseif { $arg == "-t" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set test_name [lindex $argv $index]
+        set no 0
+        foreach test $test_suite {
+            if { $test_name != $test } {
+                set no [expr $no + 1]
+            }
+        }
+        if { $no == [llength $test_suite] } {
+            print_help tests
+            exit 1
+        }
+    }       
+}
+
+# Run tests
+if { $test_name != ""} {
+    cd test/$test_name
+
+    set result [eval exec tclsh test.tcl $arguments]
+    puts $result
+
+} else {
+    foreach test $test_suite {
+        cd test/$test
+    
+        set result [eval exec tclsh test.tcl $arguments]
+        puts $result
+    
+        cd ../..
+    }
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130707/fff81f6f/attachment.html>


More information about the macports-changes mailing list