Merge pull request #1377 from Exiv2/feature_1372_support_env_variables
Fix_1372_env_vars_0.27
This commit is contained in:
commit
298aa86575
@ -64,10 +64,10 @@ Ubuntu:
|
||||
# <<: *default_config
|
||||
# <<: *distro_build
|
||||
|
||||
OpenSUSE:
|
||||
image: opensuse/tumbleweed
|
||||
<<: *default_config
|
||||
<<: *distro_build
|
||||
# OpenSUSE:
|
||||
# image: opensuse/tumbleweed
|
||||
# <<: *default_config
|
||||
# <<: *distro_build
|
||||
|
||||
Install:
|
||||
image: fedora:latest
|
||||
|
||||
@ -153,8 +153,8 @@ python_tests:
|
||||
@echo
|
||||
@echo ---- Running python_tests ----
|
||||
@echo
|
||||
@echo bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose ;fi ; python3 runner.py $$verbose '
|
||||
@bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose ;fi ; python3 runner.py $$verbose '
|
||||
@echo bash -c 'cd ../tests; python3 runner.py'
|
||||
@bash -c 'cd ../tests; python3 runner.py'
|
||||
|
||||
mostlyclean clean:
|
||||
rm -rf $(top_srcdir)/test/tmp/*
|
||||
|
||||
@ -375,17 +375,16 @@ checkSum()
|
||||
}
|
||||
|
||||
##
|
||||
# startHttpServer - power up the python web server
|
||||
# startServer - power up the python web server
|
||||
startHttpServer() {
|
||||
cd "${testdir}/.." # testdir is the tmp output directory
|
||||
|
||||
if [ "$platform" == "cygwin" ]; then dport=12762
|
||||
elif [ "$platform" == "mingw" ]; then dport=12761
|
||||
else dport=12760
|
||||
if [ "$platform" == "platform=cygwin" ]; then dport=12762
|
||||
elif [ "$platform" == "platform=mingw64" ]; then dport=12761
|
||||
else dport=12760
|
||||
fi
|
||||
|
||||
if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=$dport ; fi
|
||||
if [ ! -z $EXIV2_HTTP ]; then http=$EXIV2_HTTP ; else http=http://localhost; fi
|
||||
if [ ! -z "$EXIV2_PORT" ]; then port=$EXIV2_PORT ; else port=$dport ; fi
|
||||
if [ ! -z "$EXIV2_HTTP" ]; then http=$EXIV2_HTTP ; else http=http://localhost; fi
|
||||
exiv2_url=$http:$port
|
||||
python3 -m http.server $port & # start a background local HTTP server in the "real" test directory
|
||||
sleep 2 # wait for it to init or die!
|
||||
@ -418,7 +417,7 @@ prepareTest()
|
||||
os=$(uname -o)
|
||||
if [ $os == Cygwin ]; then
|
||||
PLATFORM=cygwin
|
||||
elif [ os == Msys ]; then
|
||||
elif [ $os == Msys ]; then
|
||||
PLATFORM=mingw
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -564,22 +564,28 @@ set Exif.Photo.DateTimeDigitized 2020:05:26 07:31:42
|
||||
|
||||
def io_test(self):
|
||||
# Test driver for file i/o
|
||||
test_files = ['table.jpg', 'smiley2.jpg', 'ext.dat']
|
||||
test_files = ['table.jpg', 'smiley2.jpg', 'ext.dat']
|
||||
for f in test_files:
|
||||
BT.copyTestFile(f)
|
||||
BT.ioTest(f)
|
||||
|
||||
# Test http I/O
|
||||
def sniff(*files):
|
||||
result = [str(os.path.getsize(i)) for i in files]
|
||||
result += [BT.md5sum(i) for i in files]
|
||||
result = [str(os.path.getsize(i)) for i in files]
|
||||
result += [BT.md5sum(i) for i in files]
|
||||
return ' '.join(result)
|
||||
|
||||
server_url = '{}:{}'.format(BT.Config.exiv2_http,
|
||||
BT.Config.exiv2_port)
|
||||
server = BT.HttpServer(bind=BT.Config.exiv2_http.lstrip('http://'),
|
||||
port=BT.Config.exiv2_port,
|
||||
work_dir=BT.Config.data_dir)
|
||||
exiv2_http = BT.Config.exiv2_http
|
||||
exiv2_port = BT.Config.exiv2_port
|
||||
if not exiv2_http or not exiv2_port:
|
||||
print('Skipped http test. Because of invalid environment variables: EXIV2_HTTP={} EXIV2_PORT={}'.format(
|
||||
exiv2_http, exiv2_port))
|
||||
return
|
||||
server_url = '{}:{}'.format(exiv2_http,
|
||||
exiv2_port)
|
||||
server = BT.HttpServer(bind=exiv2_http.lstrip('http://'),
|
||||
port=exiv2_port, # It can be of type int or str
|
||||
work_dir=BT.Config.data_dir)
|
||||
try:
|
||||
server.start()
|
||||
out = BT.Output()
|
||||
|
||||
@ -21,13 +21,24 @@ Here is the configuration part of test cases.
|
||||
class Config:
|
||||
# The configuration parameters for bash test
|
||||
# When you run the test cases through `python3 runner.py`, the function configure_suite() in system_tests.py will override these parameters.
|
||||
exiv2_dir = os.path.normpath(os.path.join(os.path.abspath(__file__), '../../../'))
|
||||
bin_dir = os.path.join(exiv2_dir, 'build/bin')
|
||||
data_dir = os.path.join(exiv2_dir, 'test/data')
|
||||
tmp_dir = os.path.join(exiv2_dir, 'test/tmp')
|
||||
system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc.
|
||||
exiv2_http = 'http://127.0.0.1'
|
||||
exiv2_port = 12760
|
||||
exiv2_dir = os.path.normpath(os.path.join(os.path.abspath(__file__), '../../../'))
|
||||
bin_dir = os.path.join(exiv2_dir, 'build/bin')
|
||||
if 'EXIV2_BINDIR' in os.environ:
|
||||
bin_dir = os.environ['EXIV2_BINDIR']
|
||||
dyld_library_path = os.path.join(bin_dir, '../lib')
|
||||
ld_library_path = os.path.join(bin_dir, '../lib')
|
||||
data_dir = os.path.join(exiv2_dir, 'test/data')
|
||||
tmp_dir = os.path.join(exiv2_dir, 'test/tmp')
|
||||
system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc.
|
||||
exiv2_http = 'http://127.0.0.1'
|
||||
exiv2_port = '12760'
|
||||
valgrind = ''
|
||||
if 'EXIV2_PORT' in os.environ:
|
||||
exiv2_port = os.environ['EXIV2_PORT']
|
||||
if 'EXIV2_HTTP' in os.environ:
|
||||
exiv2_http = os.environ['EXIV2_HTTP']
|
||||
if 'VALGRIND' in os.environ:
|
||||
valgrind = os.environ['VALGRIND']
|
||||
|
||||
@classmethod
|
||||
def init(cls):
|
||||
@ -422,6 +433,8 @@ class Executer:
|
||||
|
||||
# set environment variables
|
||||
self.env = os.environ.copy()
|
||||
self.env.update({'DYLD_LIBRARY_PATH': Config.dyld_library_path})
|
||||
self.env.update({'LD_LIBRARY_PATH': Config.ld_library_path})
|
||||
self.env.update({'TZ': 'GMT-8'})
|
||||
self.env.update(extra_env)
|
||||
|
||||
@ -444,6 +457,9 @@ class Executer:
|
||||
self.args = args.replace('\'', '\"')
|
||||
else:
|
||||
self.args = shlex.split(args, posix=os.name == 'posix')
|
||||
|
||||
if len(Config.valgrind)>0:
|
||||
self.args = [ Config.valgrind ] + self.args
|
||||
|
||||
# Check stdin
|
||||
if self.stdin:
|
||||
|
||||
@ -62,9 +62,11 @@ if __name__ == '__main__':
|
||||
nargs='?'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
conf_file = args.config_file[0]
|
||||
DEFAULT_ROOT = os.path.abspath(os.path.dirname(conf_file))
|
||||
args = parser.parse_args()
|
||||
if 'VERBOSE' in os.environ:
|
||||
args.verbose = 2
|
||||
conf_file = args.config_file[0]
|
||||
DEFAULT_ROOT = os.path.abspath(os.path.dirname(conf_file))
|
||||
system_tests.set_debug_mode(args.debug)
|
||||
system_tests.configure_suite(conf_file)
|
||||
|
||||
|
||||
@ -4,14 +4,23 @@ memcheck: ${ENV:valgrind}
|
||||
|
||||
[ENV]
|
||||
exiv2_path: EXIV2_BINDIR
|
||||
valgrind: EXIV2_VALGRIND
|
||||
dyld_library_path: DYLD_LIBRARY_PATH
|
||||
ld_library_path: LD_LIBRARY_PATH
|
||||
exiv2_http: EXIV2_HTTP
|
||||
exiv2_port: EXIV2_PORT
|
||||
exiv2_echo: EXIV2_ECHO
|
||||
verbose: VERBOSE
|
||||
valgrind: VALGRIND
|
||||
|
||||
[ENV fallback]
|
||||
exiv2_path: ../build/bin
|
||||
dyld_library_path: ${ENV:exiv2_path}/../lib
|
||||
ld_library_path: ${ENV:exiv2_path}/../lib
|
||||
exiv2_http: http://127.0.0.1
|
||||
exiv2_port: 12760
|
||||
exiv2_echo:
|
||||
verbose:
|
||||
valgrind:
|
||||
|
||||
[paths]
|
||||
exiv2: ${ENV:exiv2_path}/exiv2
|
||||
|
||||
@ -154,13 +154,12 @@ def configure_suite(config_file):
|
||||
)
|
||||
)
|
||||
|
||||
# extract variables from the environment
|
||||
# Extract the environment variables according to config['ENV'].
|
||||
# When an environment variable does not exist, set its default value according to config['ENV fallback'].
|
||||
for key in config['ENV']:
|
||||
if key in config['ENV fallback']:
|
||||
fallback = config['ENV fallback'][key]
|
||||
else:
|
||||
fallback = ""
|
||||
config['ENV'][key] = os.getenv(config['ENV'][key]) or fallback
|
||||
env_name = config['ENV'][key]
|
||||
env_fallback = config['ENV fallback'].get(key, '')
|
||||
config['ENV'][key] = os.environ.get(env_name, env_fallback)
|
||||
|
||||
if 'variables' in config:
|
||||
for key in config['variables']:
|
||||
@ -202,12 +201,16 @@ def configure_suite(config_file):
|
||||
)
|
||||
|
||||
# Configure the parameters for bash tests
|
||||
BT.Config.bin_dir = os.path.abspath(config['ENV']['exiv2_path'])
|
||||
BT.Config.data_dir = os.path.abspath(config['paths']['data_path'])
|
||||
BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path'])
|
||||
BT.Config.exiv2_http = config['ENV']['exiv2_http']
|
||||
BT.Config.exiv2_port = int(config['ENV']['exiv2_port'])
|
||||
# print(dict(config['ENV'])); exit(1) # for debug
|
||||
BT.Config.bin_dir = os.path.abspath(config['ENV']['exiv2_path'])
|
||||
BT.Config.dyld_library_path = os.path.abspath(config['ENV']['dyld_library_path'])
|
||||
BT.Config.ld_library_path = os.path.abspath(config['ENV']['ld_library_path'])
|
||||
BT.Config.data_dir = os.path.abspath(config['paths']['data_path'])
|
||||
BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path'])
|
||||
BT.Config.exiv2_http = config['ENV']['exiv2_http']
|
||||
BT.Config.exiv2_port = config['ENV']['exiv2_port']
|
||||
BT.Config.exiv2_echo = config['ENV']['exiv2_echo']
|
||||
BT.Config.verbose = config['ENV']['verbose']
|
||||
BT.Config.valgrind = config['ENV']['valgrind']
|
||||
|
||||
|
||||
class FileDecoratorBase(object):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user