diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2013-08-29 21:06:10 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2013-08-29 21:06:10 +0000 |
| commit | 4d331e73a76dce7d703716093923ca01b3cc5936 (patch) | |
| tree | b444657ba269b25f60684e66858a138b74fe240d /share/extensions/test | |
| parent | Fix compiler warnings (diff) | |
| parent | Updating outdated test. Fixes bug #1202271. (diff) | |
| download | inkscape-4d331e73a76dce7d703716093923ca01b3cc5936.tar.gz inkscape-4d331e73a76dce7d703716093923ca01b3cc5936.zip | |
merge from trunk (r12487)
(bzr r11668.1.75)
Diffstat (limited to 'share/extensions/test')
| -rwxr-xr-x | share/extensions/test/render_gears.test.py (renamed from share/extensions/test/gears.test.py) | 2 | ||||
| -rwxr-xr-x | share/extensions/test/run-all-extension-tests | 54 | ||||
| -rwxr-xr-x | share/extensions/test/simplestyle.test.py | 122 |
3 files changed, 113 insertions, 65 deletions
diff --git a/share/extensions/test/gears.test.py b/share/extensions/test/render_gears.test.py index 964f675ad..ad1668126 100755 --- a/share/extensions/test/gears.test.py +++ b/share/extensions/test/render_gears.test.py @@ -10,7 +10,7 @@ import sys sys.path.append('..') # this line allows to import the extension code import unittest -from gears import * +from render_gears import * class GearsBasicTest(unittest.TestCase): diff --git a/share/extensions/test/run-all-extension-tests b/share/extensions/test/run-all-extension-tests index 1776e25b0..aa20c8c7b 100755 --- a/share/extensions/test/run-all-extension-tests +++ b/share/extensions/test/run-all-extension-tests @@ -1,12 +1,39 @@ #!/bin/bash +# TODO: check for GNU mktemp and sed (from coreutils), else exit +# --------------------------------------------------------------------- +# solution below is based on +# <http://www.ooblick.com/weblog/2011/05/12/a-couple-of-shell-quickies/> + +# Wrapper function for GNU mktemp +gnu_mktemp() { + mktemp "$@" +} + +# Wrapper function for BSD mktemp +bsd_mktemp() { + mktemp -t tmpfile.XXXXXX "$@" +} + +# Try to figure out which wrapper to use +if mktemp -V | grep version >/dev/null 2>&1; then + MKTEMP=gnu_mktemp +else + MKTEMP=bsd_mktemp +fi + +#mytmpfile=`$MKTEMP` +echo "MKTEMP to be used: $MKTEMP" + +# --------------------------------------------------------------------- + echo -e "\n##### Extension Tests #####" cd "$(dirname "$0")" has_py_coverage=false -py_cover_files=$( mktemp ) -failed_tests=$( mktemp ) +py_cover_files=$( $MKTEMP ) +failed_tests=$( $MKTEMP ) if coverage.py -e >/dev/null 2>/dev/null; then has_py_coverage=true @@ -39,8 +66,23 @@ function run_py_test() { tot_FAILED=0 +# TODO: check for GNU mktemp and sed (from coreutils), else exit +# --------------------------------------------------------------------- +# solution below is based on +# <http://notmuchmail.org/pipermail/notmuch/2011/004579.html> + +if [ `sed --version >/dev/null 2>/dev/null && echo 1` ]; then + SED_EXTENDED='sed -r' # GNU sed (e.g. on Linux) +else + SED_EXTENDED='sed -E' # BSD sed (e.g. on Mac OS X) +fi + +echo "sed regex command: $SED_EXTENDED" + +# --------------------------------------------------------------------- + for testFile in *.test.py; do - if ! run_py_test $( echo $testFile | sed -r 's/^([^.]+)..*$/\1/' ); then + if ! run_py_test $( echo $testFile | $SED_EXTENDED 's/^([^.]+)..*$/\1/' ); then let tot_FAILED++ fi done @@ -60,4 +102,8 @@ echo "" rm $py_cover_files $failed_tests -$fail && exit 1
\ No newline at end of file +if [ x$fail == xtrue ]; then + exit 1 +else + exit 0 +fi diff --git a/share/extensions/test/simplestyle.test.py b/share/extensions/test/simplestyle.test.py index 3c75ac43a..a4746ec09 100755 --- a/share/extensions/test/simplestyle.test.py +++ b/share/extensions/test/simplestyle.test.py @@ -1,63 +1,65 @@ #!/usr/bin/env python -import unittest, sys
-sys.path.append('..') # this line allows to import the extension code
-
-from simplestyle import parseColor, parseStyle
-
-
-class ParseColorTest(unittest.TestCase):
- """Test for single transformations"""
- def test_namedcolor(self):
- "Parse 'red'"
- col = parseColor('red')
- self.failUnlessEqual((255,0,0),col)
-
- def test_hexcolor4digit(self):
- "Parse '#ff0102'"
- col = parseColor('#ff0102')
- self.failUnlessEqual((255,1,2),col)
-
- def test_hexcolor3digit(self):
- "Parse '#fff'"
- col = parseColor('#fff')
- self.failUnlessEqual((255,255,255),col)
-
- def test_rgbcolorint(self):
- "Parse 'rgb(255,255,255)'"
- col = parseColor('rgb(255,255,255)')
- self.failUnlessEqual((255,255,255),col)
-
- def test_rgbcolorpercent(self):
- "Parse 'rgb(100%,100%,100%)'"
- col = parseColor('rgb(100%,100%,100%)')
- self.failUnlessEqual((255,255,255),col)
-
- def test_rgbcolorpercent2(self):
- "Parse 'rgb(100%,100%,100%)'"
- col = parseColor('rgb(50%,0%,1%)')
- self.failUnlessEqual((127,0,2),col)
-
- def test_rgbcolorpercentdecimal(self):
- "Parse 'rgb(66.667%,0%,6.667%)'"
- col = parseColor('rgb(66.667%,0%,6.667%)')
- self.failUnlessEqual((170, 0, 17),col)
-
- def test_currentColor(self):
- "Parse 'currentColor'"
- col = parseColor('currentColor')
- self.failUnlessEqual(('currentColor'),col)
-
- def test_spaceinstyle(self):
- "Parse 'stop-color: rgb(0,0,0)'"
- col = parseStyle('stop-color: rgb(0,0,0)')
- self.failUnlessEqual({'stop-color': 'rgb(0,0,0)'},col)
-
- #def test_unknowncolor(self):
- # "Parse 'unknown'"
- # col = parseColor('unknown')
- # self.failUnlessEqual((0,0,0),col)
- #
-
-if __name__ == '__main__':
+import unittest, sys +sys.path.append('..') # this line allows to import the extension code + +from simplestyle import parseColor, parseStyle + + +class ParseColorTest(unittest.TestCase): + """Test for single transformations""" + def test_namedcolor(self): + "Parse 'red'" + col = parseColor('red') + self.failUnlessEqual((255,0,0),col) + + def test_hexcolor4digit(self): + "Parse '#ff0102'" + col = parseColor('#ff0102') + self.failUnlessEqual((255,1,2),col) + + def test_hexcolor3digit(self): + "Parse '#fff'" + col = parseColor('#fff') + self.failUnlessEqual((255,255,255),col) + + def test_rgbcolorint(self): + "Parse 'rgb(255,255,255)'" + col = parseColor('rgb(255,255,255)') + self.failUnlessEqual((255,255,255),col) + + def test_rgbcolorpercent(self): + "Parse 'rgb(100%,100%,100%)'" + col = parseColor('rgb(100%,100%,100%)') + self.failUnlessEqual((255,255,255),col) + + def test_rgbcolorpercent2(self): + "Parse 'rgb(100%,100%,100%)'" + col = parseColor('rgb(50%,0%,1%)') + self.failUnlessEqual((127,0,2),col) + + def test_rgbcolorpercentdecimal(self): + "Parse 'rgb(66.667%,0%,6.667%)'" + col = parseColor('rgb(66.667%,0%,6.667%)') + self.failUnlessEqual((170, 0, 17),col) + + # TODO: This test appears to be broken. parseColor can + # only return an RGB colour code + #def test_currentColor(self): + # "Parse 'currentColor'" + # col = parseColor('currentColor') + # self.failUnlessEqual(('currentColor'),col) + + def test_spaceinstyle(self): + "Parse 'stop-color: rgb(0,0,0)'" + col = parseStyle('stop-color: rgb(0,0,0)') + self.failUnlessEqual({'stop-color': 'rgb(0,0,0)'},col) + + #def test_unknowncolor(self): + # "Parse 'unknown'" + # col = parseColor('unknown') + # self.failUnlessEqual((0,0,0),col) + # + +if __name__ == '__main__': unittest.main() |
