Merge pull request #1377 from Exiv2/feature_1372_support_env_variables

Fix_1372_env_vars_0.27
main
Robin Mills 5 years ago committed by GitHub
commit 298aa86575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,10 +64,10 @@ Ubuntu:
# <<: *default_config # <<: *default_config
# <<: *distro_build # <<: *distro_build
OpenSUSE: # OpenSUSE:
image: opensuse/tumbleweed # image: opensuse/tumbleweed
<<: *default_config # <<: *default_config
<<: *distro_build # <<: *distro_build
Install: Install:
image: fedora:latest image: fedora:latest

@ -153,8 +153,8 @@ python_tests:
@echo @echo
@echo ---- Running python_tests ---- @echo ---- Running python_tests ----
@echo @echo
@echo 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 ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose ;fi ; python3 runner.py $$verbose ' @bash -c 'cd ../tests; python3 runner.py'
mostlyclean clean: mostlyclean clean:
rm -rf $(top_srcdir)/test/tmp/* 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() { startHttpServer() {
cd "${testdir}/.." # testdir is the tmp output directory cd "${testdir}/.." # testdir is the tmp output directory
if [ "$platform" == "platform=cygwin" ]; then dport=12762
if [ "$platform" == "cygwin" ]; then dport=12762 elif [ "$platform" == "platform=mingw64" ]; then dport=12761
elif [ "$platform" == "mingw" ]; then dport=12761
else dport=12760 else dport=12760
fi fi
if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=$dport ; 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_HTTP" ]; then http=$EXIV2_HTTP ; else http=http://localhost; fi
exiv2_url=$http:$port exiv2_url=$http:$port
python3 -m http.server $port & # start a background local HTTP server in the "real" test directory 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! sleep 2 # wait for it to init or die!
@ -418,7 +417,7 @@ prepareTest()
os=$(uname -o) os=$(uname -o)
if [ $os == Cygwin ]; then if [ $os == Cygwin ]; then
PLATFORM=cygwin PLATFORM=cygwin
elif [ os == Msys ]; then elif [ $os == Msys ]; then
PLATFORM=mingw PLATFORM=mingw
fi fi
fi fi

@ -575,10 +575,16 @@ set Exif.Photo.DateTimeDigitized 2020:05:26 07:31:42
result += [BT.md5sum(i) for i in files] result += [BT.md5sum(i) for i in files]
return ' '.join(result) return ' '.join(result)
server_url = '{}:{}'.format(BT.Config.exiv2_http, exiv2_http = BT.Config.exiv2_http
BT.Config.exiv2_port) exiv2_port = BT.Config.exiv2_port
server = BT.HttpServer(bind=BT.Config.exiv2_http.lstrip('http://'), if not exiv2_http or not exiv2_port:
port=BT.Config.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) work_dir=BT.Config.data_dir)
try: try:
server.start() server.start()

@ -23,11 +23,22 @@ class Config:
# When you run the test cases through `python3 runner.py`, the function configure_suite() in system_tests.py will override these parameters. # 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__), '../../../')) exiv2_dir = os.path.normpath(os.path.join(os.path.abspath(__file__), '../../../'))
bin_dir = os.path.join(exiv2_dir, 'build/bin') 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') data_dir = os.path.join(exiv2_dir, 'test/data')
tmp_dir = os.path.join(exiv2_dir, 'test/tmp') tmp_dir = os.path.join(exiv2_dir, 'test/tmp')
system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc. system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc.
exiv2_http = 'http://127.0.0.1' exiv2_http = 'http://127.0.0.1'
exiv2_port = 12760 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 @classmethod
def init(cls): def init(cls):
@ -422,6 +433,8 @@ class Executer:
# set environment variables # set environment variables
self.env = os.environ.copy() 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({'TZ': 'GMT-8'})
self.env.update(extra_env) self.env.update(extra_env)
@ -445,6 +458,9 @@ class Executer:
else: else:
self.args = shlex.split(args, posix=os.name == 'posix') self.args = shlex.split(args, posix=os.name == 'posix')
if len(Config.valgrind)>0:
self.args = [ Config.valgrind ] + self.args
# Check stdin # Check stdin
if self.stdin: if self.stdin:
if not isinstance(stdin, bytes): if not isinstance(stdin, bytes):

@ -63,6 +63,8 @@ if __name__ == '__main__':
) )
args = parser.parse_args() args = parser.parse_args()
if 'VERBOSE' in os.environ:
args.verbose = 2
conf_file = args.config_file[0] conf_file = args.config_file[0]
DEFAULT_ROOT = os.path.abspath(os.path.dirname(conf_file)) DEFAULT_ROOT = os.path.abspath(os.path.dirname(conf_file))
system_tests.set_debug_mode(args.debug) system_tests.set_debug_mode(args.debug)

@ -4,14 +4,23 @@ memcheck: ${ENV:valgrind}
[ENV] [ENV]
exiv2_path: EXIV2_BINDIR exiv2_path: EXIV2_BINDIR
valgrind: EXIV2_VALGRIND dyld_library_path: DYLD_LIBRARY_PATH
ld_library_path: LD_LIBRARY_PATH
exiv2_http: EXIV2_HTTP exiv2_http: EXIV2_HTTP
exiv2_port: EXIV2_PORT exiv2_port: EXIV2_PORT
exiv2_echo: EXIV2_ECHO
verbose: VERBOSE
valgrind: VALGRIND
[ENV fallback] [ENV fallback]
exiv2_path: ../build/bin 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_http: http://127.0.0.1
exiv2_port: 12760 exiv2_port: 12760
exiv2_echo:
verbose:
valgrind:
[paths] [paths]
exiv2: ${ENV:exiv2_path}/exiv2 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']: for key in config['ENV']:
if key in config['ENV fallback']: env_name = config['ENV'][key]
fallback = config['ENV fallback'][key] env_fallback = config['ENV fallback'].get(key, '')
else: config['ENV'][key] = os.environ.get(env_name, env_fallback)
fallback = ""
config['ENV'][key] = os.getenv(config['ENV'][key]) or fallback
if 'variables' in config: if 'variables' in config:
for key in config['variables']: for key in config['variables']:
@ -203,11 +202,15 @@ def configure_suite(config_file):
# Configure the parameters for bash tests # Configure the parameters for bash tests
BT.Config.bin_dir = os.path.abspath(config['ENV']['exiv2_path']) 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.data_dir = os.path.abspath(config['paths']['data_path'])
BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path']) BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path'])
BT.Config.exiv2_http = config['ENV']['exiv2_http'] BT.Config.exiv2_http = config['ENV']['exiv2_http']
BT.Config.exiv2_port = int(config['ENV']['exiv2_port']) BT.Config.exiv2_port = config['ENV']['exiv2_port']
# print(dict(config['ENV'])); exit(1) # for debug BT.Config.exiv2_echo = config['ENV']['exiv2_echo']
BT.Config.verbose = config['ENV']['verbose']
BT.Config.valgrind = config['ENV']['valgrind']
class FileDecoratorBase(object): class FileDecoratorBase(object):

Loading…
Cancel
Save