#!/bin/sh -e
# vim: set sts=4 expandtab:
# Copyright (C) 2026 Osamu Aoki <osamu@debian.org>
IM_CONFIG_ENTRY="im-config-test"
export IM_CONFIG_ENTRY

HOME=.
export HOME

echo "autopackage test $IM_CONFIG_ENTRY UID=$(id -u)"

ERRORS=""
if [ "$(im-config -o auto|head -1)" != "N/A" ]; then
  im-config -o auto|head -1
  echo
  ERRORS="*$ERRORS"
fi
if [ "$(im-config -o default|head -1)" != "N/A" ]; then
  im-config -o default|head -1
  echo
  ERRORS="*$ERRORS"
fi
if [ "$(im-config -o REMOVE|head -1)" != "N/A" ]; then
  im-config -o REMOVE|head -1
  echo
  ERRORS="*$ERRORS"
fi
if [ "$(im-config -o none|head -1)" != "This does not activate any IM from im-config." ]; then
  im-config -o none|head -1
  echo
  ERRORS="*$ERRORS"
fi
if [ -z "$(im-config -l -a)" ]; then
  echo "im-config -l -a without output"
  ERRORS="*$ERRORS"
fi

im-config -n none
if [ ! -e "$HOME/.xinputrc" ]; then
  echo "'im-config -n none' doesn't create .xinputrc"
  ERRORS="*$ERRORS"
fi
rm .xinputrc

echo "ERRORS='$ERRORS'"

if [ -z "$ERORRS" ]; then
  echo "SUCCESS"
  exit 0
else
  echo "FAILURE"
  exit 1
fi

