Commit 15c21fa4 authored by Eduard's avatar Eduard

#19: Set env in tests and replace `ninja run` with run_with_dia_env.sh.

  - This was the more elegant solution as it allows tests to be ran
    under a specific environment and at the same time it allows us to
    run the dia app under any sort of harness we want.
  - Note that this fixes neduard/dia#2.
parent f5386845
......@@ -74,7 +74,7 @@ endif
diaapp_inc = include_directories('.')
rundeps += executable('dia',
diaapp = executable('dia',
dia_sources + [dia_app_icons_h, diamarshal_h],
dependencies : [libgtk_dep, libxml_dep, libm_dep],
link_with : [libdia],
......@@ -85,3 +85,5 @@ rundeps += executable('dia',
install : true,
install_rpath : dialibdir
)
rundeps += diaapp
#!/usr/bin/env sh
if [ ! -d "$2" ] || [ ! -d "$3" ]; then
echo Unable to find both directory $2 and $3.
fi
SOURCE_ROOT=$2
BUILD_ROOT=$3
# This unfortunately is a duplication of run_env in
# tests/meson.build. This is fine as long as this
# script is only used to generate run_with_dia_env
# and only that.
cat > $1 << EOF
#!/usr/bin/env sh
export DIA_BASE_PATH=${SOURCE_ROOT}
export DIA_LIB_PATH=${BUILD_ROOT}/objects:${BUILD_ROOT}/plug-ins
export DIA_SHAPE_PATH=${SOURCE_ROOT}/shapes
export DIA_XSLT_PATH=${SOURCE_ROOT}/plug-ins/xslt
export DIA_PYTHON_PATH=${SOURCE_ROOT}/plug-ins/python
export DIA_SHEET_PATH=${BUILD_ROOT}/sheets
\$@
EOF
chmod u+x $1
......@@ -74,6 +74,7 @@ configure_file(output : 'config.h',
# To fix we should remove #ifdef HAVE_CONFIG_H checks from all source files.
add_project_arguments('-DHAVE_CONFIG_H', language : 'c')
# Keep track of everything that is needed for running dia
rundeps = []
subdir('po')
......@@ -87,10 +88,17 @@ subdir('sheets')
subdir('shapes')
subdir('tests')
# Convenience target
run_target('run',
command: [run_dia],
depends: rundeps,
# This is a convenience target to create a way to run dia from
# command line.
custom_target('run_with_dia_env',
command: [find_program('generate_run_with_dia_env.sh'),
'@OUTPUT@',
meson.source_root(),
meson.build_root()
],
output: 'run_with_dia_env',
# Ensure we always generate this in the build directory.
build_by_default: true
)
meson.add_install_script('meson-helpers/post-install.py', datadir)
exports_test = find_program('exports_test.sh')
test('exports',
exports_test,
args: [run_dia.path()],
find_program('exports_test.sh'),
args: [
# TODO: this is a bug in meson. We don't need to
# specify full_path() https://github.com/mesonbuild/meson/issues/2681
diaapp.full_path()],
workdir: meson.current_source_dir(),
env: [
'MESON_BUILD_ROOT=' + meson.build_root(),
'MESON_SOURCE_ROOT=' + meson.source_root(),
],
env: run_env,
)
run_dia = find_program('run_dia.sh')
# Setup local environment to run dia.
run_env = environment()
run_env.set('DIA_BASE_PATH', meson.source_root())
run_env.append('DIA_LIB_PATH',
join_paths(meson.build_root(), 'objects'),
join_paths(meson.build_root(), 'plug-ins'))
run_env.set('DIA_SHAPE_PATH', join_paths(meson.source_root(), 'shapes'))
run_env.set('DIA_XSLT_PATH', join_paths(meson.source_root(), 'plug-ins', 'xslt'))
run_env.set('DIA_PYTHON_PATH', join_paths(meson.source_root(), 'plug-ins', 'python'))
run_env.set('DIA_SHEET_PATH', join_paths(meson.build_root(), 'sheets'))
# TODO: minimise code duplication.
if host_machine.system() != 'windows'
......@@ -54,14 +62,11 @@ find_program('xmllint', required: true)
test('xmllint',
xmllint_test,
args: [
run_dia.path(),
diaapp,
shape_dtd,
render_test_dia
],
env: [
'MESON_BUILD_ROOT=' + meson.build_root(),
'MESON_SOURCE_ROOT=' + meson.source_root(),
],
env: run_env,
)
test('testsvg', tsvg)
......
#!/usr/bin/env sh
if [ ! -d "${MESON_SOURCE_ROOT}" ]; then
echo "Please supply MESON_SOURCE_ROOT variable"
exit 1
fi
if [ ! -d "${MESON_BUILD_ROOT}" ]; then
echo "Please supply MESON_BUILD_ROOT variable"
exit 2
fi
export DIA_BASE_PATH="${MESON_SOURCE_ROOT}"
export DIA_LIB_PATH="${MESON_BUILD_ROOT}/objects/:${MESON_BUILD_ROOT}/plug-ins"
export DIA_SHAPE_PATH="${MESON_SOURCE_ROOT}/shapes/"
export DIA_SHEET_PATH="${MESON_BUILD_ROOT}/sheets"
export DIA_XSLT_PATH="${MESON_SOURCE_ROOT}/plug-ins/xslt/"
export DIA_PYTHON_PATH="${MESON_SOURCE_ROOT}/plug-ins/python/"
${MESON_BUILD_ROOT}/app/dia "$@"
#!/usr/bin/env sh
RUN_DIA=$1
DIA=$1
SHAPE_DTD=$2
DIAGRAM=$3
......@@ -9,7 +8,7 @@ FAILED=0
set -x
# TODO: can we use mktemp instead of rt.shape?
${RUN_DIA} ${DIAGRAM} --export=rt.shape || exit 1
${DIA} ${DIAGRAM} --export=rt.shape || exit 1
xmllint --dtdvalid ${SHAPE_DTD} rt.shape || exit 2
rm -f rt.shape
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment