#!/bin/sh

# $Id: test,v 1.2 1999/11/23 11:07:42 jdg Exp $
# Copyright 1999 Julian Gilbey <jdg@debian.org>
# Based on example debian-test/grep program:
# Copyright (c) 1998  Philip Hands <phil@hands.com>
# This program is distributed under the terms of the GPL.

# Test script, for use with the debian-test package, for
# testing that devscripts is vaguely working.

# I'm adding tests to this script as I notice myself making errors
# which could be repeatable.

# check that devscripts is installed
test -e /usr/bin/debuild || exit 0

# Work in C locale
unset LC_ALL LANG LC_MESSAGES

. ${DEBIANTEST_LIB}/functions.sh

test_version_number() {
    echo "I have a habit of forgetting to change the version number"
    echo "in configure.in.  This test checks that I have remembered."
    PKG_VERSION=`dpkg -l devscripts | awk '/devscripts/ { print $3 }'`
    CONFIG_VERSION=`debuild --version |
	sed -n -e '/debuild/s/.*version \([0-9\.]*\).*/\1/p'`
    printmsg "package version = $PKG_VERSION, configure.in version = $CONFIG_VERSION"
    test "$PKG_VERSION" = "$CONFIG_VERSION"
}

test_perl_shebang() {
    echo "I have a habit of forgetting set my PATH to exclude /usr/local/bin"
    echo "when compiling, and I have a /usr/local/bin/perl on my system."
    echo "This test checks that I have got this correct."
    printmsg "Typical shebang line: " `head -1 /usr/bin/debpkg`
    grep -q '#! /usr/bin/perl' /usr/bin/debpkg
}

runtest "Version numbering"     test_version_number
runtest "Perl shebang line"     test_perl_shebang
