2011-01-05 21:52:08 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from nose.tools import *
|
2013-06-03 04:28:24 +02:00
|
|
|
from utilities import execution_path, run_all
|
2013-03-14 03:49:59 +01:00
|
|
|
from subprocess import Popen, PIPE, STDOUT
|
2011-01-05 21:52:08 +01:00
|
|
|
import os
|
|
|
|
|
2013-03-14 03:49:59 +01:00
|
|
|
import os, sys, glob, mapnik
|
|
|
|
|
|
|
|
def test_mapnik_config_no_args():
|
|
|
|
process = Popen('mapnik-config', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
|
|
result = process.communicate()
|
|
|
|
eq_('Usage: mapnik-config ' in result[0],True)
|
|
|
|
eq_(result[1],'')
|
2013-05-26 04:54:53 +02:00
|
|
|
eq_(process.returncode,1)
|
2013-03-14 03:49:59 +01:00
|
|
|
|
|
|
|
def test_mapnik_config_help():
|
|
|
|
process = Popen('mapnik-config --help', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
|
|
result = process.communicate()
|
|
|
|
eq_('Usage: mapnik-config ' in result[0],True)
|
|
|
|
eq_(result[1],'')
|
2013-05-26 04:54:53 +02:00
|
|
|
eq_(process.returncode,0)
|
2013-03-14 03:49:59 +01:00
|
|
|
|
|
|
|
def test_mapnik_config_help_short():
|
|
|
|
process = Popen('mapnik-config -h', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
|
|
result = process.communicate()
|
|
|
|
eq_('Usage: mapnik-config ' in result[0],True)
|
|
|
|
eq_(result[1],'')
|
2013-05-26 04:54:53 +02:00
|
|
|
eq_(process.returncode,0)
|
2013-03-14 03:49:59 +01:00
|
|
|
|
|
|
|
def test_mapnik_config_valid_opts():
|
|
|
|
valid_args = [
|
|
|
|
'-h',
|
|
|
|
'--help',
|
|
|
|
'-v',
|
|
|
|
'--version',
|
2013-05-10 22:47:04 +02:00
|
|
|
'--version-number',
|
2013-03-14 03:49:59 +01:00
|
|
|
'--git-revision',
|
|
|
|
'--git-describe',
|
|
|
|
'--fonts',
|
|
|
|
'--input-plugins',
|
|
|
|
'--defines',
|
|
|
|
'--prefix',
|
|
|
|
'--lib-name',
|
|
|
|
'--libs',
|
|
|
|
'--dep-libs',
|
|
|
|
'--ldflags',
|
|
|
|
'--includes',
|
|
|
|
'--dep-includes',
|
|
|
|
'--cxxflags',
|
2013-05-10 22:47:04 +02:00
|
|
|
'--cflags',
|
|
|
|
'--all-flags',
|
|
|
|
'--cxx'
|
2013-03-14 03:49:59 +01:00
|
|
|
]
|
|
|
|
for item in valid_args:
|
|
|
|
cmd = 'mapnik-config ' + item
|
|
|
|
process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
|
|
result = process.communicate()
|
|
|
|
eq_(process.returncode,0)
|
|
|
|
eq_(len(result[0]) > 1,True,cmd)
|
|
|
|
eq_(result[1],'')
|
|
|
|
|
|
|
|
def test_mapnik_config_invalid_option():
|
|
|
|
cmd = 'mapnik-config --invalid-does-not-exist'
|
|
|
|
process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
|
|
result = process.communicate()
|
|
|
|
eq_(process.returncode,0)
|
2013-05-26 04:54:53 +02:00
|
|
|
eq_(result[0].strip(),'')
|
|
|
|
eq_(result[1].strip(),'unknown option --invalid-does-not-exist')
|
2013-03-14 03:49:59 +01:00
|
|
|
|
|
|
|
def test_mapnik_config_valid_and_invalid_option():
|
|
|
|
cmd = 'mapnik-config --libs --invalid-does-not-exist'
|
|
|
|
process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
|
|
result = process.communicate()
|
2013-05-26 04:54:53 +02:00
|
|
|
eq_('mapnik' in result[0],True)
|
|
|
|
eq_(result[1].strip(),'unknown option --invalid-does-not-exist')
|
2013-03-14 03:49:59 +01:00
|
|
|
eq_(process.returncode,0)
|
2011-08-31 00:36:06 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2014-07-14 18:34:20 +02:00
|
|
|
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
|