#!/bin/bash

set -e

export $(dpkg-architecture)

# Ensuring that the compiled version of the library is deleted and not rebuilt later.
find . -type f,l -name 'libgnome-pomodoro.so*' -delete

# Build unit test with packaged library.
cd obj-*

cp /usr/lib/$DEB_HOST_MULTIARCH/libgnome-pomodoro.so src/libgnome-pomodoro.so.0.0.0
cp /usr/lib/$DEB_HOST_MULTIARCH/libgnome-pomodoro.so src/libgnome-pomodoro.so.0
cp /usr/lib/$DEB_HOST_MULTIARCH/libgnome-pomodoro.so src/libgnome-pomodoro.so
xvfb-run -a meson test

# make sure to use the right library and run test executable.
find . -type f,l -name 'libgnome-pomodoro.so*' -delete
xvfb-run -a ./tests/gnome-pomodoro-test-executable
