Test for --embedded mode.
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 29 Oct 2009 05:12:14 +0000 (22:12 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 29 Oct 2009 05:12:14 +0000 (22:12 -0700)
Demos/embed/Makefile
Demos/embed/assert_equal.py [new file with mode: 0644]
Demos/embed/embedded.output [new file with mode: 0644]

index 1356f9a2a7902c3e3c58ac8e62bb4995cb9e5f4e..4a5209e19d2424a1b7af3357b1c89124eef39559 100644 (file)
@@ -1,19 +1,23 @@
 # Makefile for creating our standalone Cython program
-PYVERSION=2.3
-PYPREFIX=/usr
+PYVERSION=$(shell python -c "import sys; print sys.version[:3]")
+PYPREFIX=$(shell python -c "import sys; print sys.prefix")
 INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
-\r
+
 embedded: embedded.o
-       gcc -o $@ $^ -lpython$(PYVERSION)\r
+       gcc -o $@ $^ -lpython$(PYVERSION)
 
 embedded.o: embedded.c
-       gcc -c $^ $(INCLUDES)\r
+       gcc -c $^ $(INCLUDES)
 
 embedded.c: embedded.pyx
-       @python ../../cython.py --embed embedded.pyx\r
+       @python ../../cython.py --embed embedded.pyx
 
 all: embedded
 
 clean:
        @echo Cleaning Demos/embed
        @rm -f *~ *.o *.so core core.* *.c embedded
+
+test: clean all
+       ./embedded > test.output
+       python assert_equal.py embedded.output test.output
diff --git a/Demos/embed/assert_equal.py b/Demos/embed/assert_equal.py
new file mode 100644 (file)
index 0000000..dfb42c5
--- /dev/null
@@ -0,0 +1,6 @@
+import sys
+if open(sys.argv[1]).read() != open(sys.argv[2]).read():
+    print "Files differ"
+    sys.exit(1)
+else:
+    print "Files identical"
diff --git a/Demos/embed/embedded.output b/Demos/embed/embedded.output
new file mode 100644 (file)
index 0000000..6b27deb
--- /dev/null
@@ -0,0 +1,2 @@
+__main__
+Hi, I'm embedded.