Project

General

Profile

Feature #1574 ยป 0075-Drop-rulesets_upgrade.sh.in-friends.patch

Marko Lindqvist, 07/06/2025 04:23 AM

View differences:

configure.ac
if test "x$ruledit" = "xyes" ; then
AC_CONFIG_FILES([fcruledit:bootstrap/fcruledit.in], [chmod +x fcruledit])
fi
AC_CONFIG_FILES([tests/rulesets_save.sh],
[chmod +x tests/rulesets_save.sh])
AC_CONFIG_FILES([tests/rulesets_upgrade.sh],
[chmod +x tests/rulesets_upgrade.sh])
AC_CONFIG_FILES([tests/rs_test_res/ruleset_loads.sh],
[chmod +x tests/rs_test_res/ruleset_loads.sh])
AC_CONFIG_FILES([tests/rulesets_autohelp.sh],
[chmod +x tests/rulesets_autohelp.sh])
tests/Makefile.am
generate_rs_save.sh \
generate_rs_upgrade.sh \
header_guard.sh \
rulesets_save.sh.in \
rulesets_upgrade.sh.in \
rs_test_res/ruleset_is.lua \
rs_test_res/ruleset_list_dist.txt \
rs_test_res/ruleset_list_opt.txt \
rs_test_res/ruleset_loads.sh.in \
rs_test_res/generate_ruleset_loads.sh \
rulesets_autohelp.sh.in \
src-check.sh \
tests/rs_test_res/ruleset_loads.sh.in
#!/usr/bin/env bash
#/***********************************************************************
# Freeciv - Copyright (C) 2017-2023
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#***********************************************************************/
# ruleset_loads.sh ruleset
# Exits with 0 when the specified ruleset is able to load. Exits with 1 if
# it fails to load.
(echo "lua unsafe-file @abs_top_srcdir@/tests/rs_test_res/ruleset_is.lua" \
| (EXPECTED_RULESET=$1 @abs_top_builddir@/fcser \
-F --Announce none --ruleset $1)) \
|| exit 1
# The ruleset was able to load.
exit 0
tests/rulesets_save.sh.in
#!/usr/bin/env bash
#/***********************************************************************
# Freeciv - Copyright (C) 2017-2025
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#***********************************************************************/
# rulesets_save.sh [ruleset]...
# Exits with 0 when each specified ruleset or, if no rulesets are specified,
# each ruleset that is developed with Freeciv, can be saved using ruleup.
# Exits with 1 if not.
# If KEEP_RESULT_IN_DIR is set to a folder the saved result will be kept
# there for later inspection even if nothing fails.
if test "$1" = "" ; then
# Try to save all rulesets that are developed with Freeciv
rulesets="$(cat @abs_top_srcdir@/tests/rs_test_res/ruleset_list_dist.txt)"
optional="$(cat @abs_top_srcdir@/tests/rs_test_res/ruleset_list_opt.txt)"
for opt in $optional ; do
if test -d "@abs_top_srcdir@/data/$opt" ; then
rulesets="$rulesets $opt"
fi
done
else
# Try to save the specified ruleset(s)
rulesets=$@
fi
if test "$KEEP_RESULT_IN_DIR" = "" ; then
# Put upgrade results in a temporary folder.
tmpdir=`mktemp -d`
else
# Save the upgrade result to the specified folder
tmpdir=$KEEP_RESULT_IN_DIR
fi
if [ -d "${tmpdir}" ] ; then
cp -R @abs_top_srcdir@/data/ruledit/ "${tmpdir}" || exit 1
cp -R @abs_top_srcdir@/data/default/ "${tmpdir}" || exit 1
else
echo "Unable to create folder for temporary files: \"${tmpdir}\""
exit 1
fi
for ruleset in $rulesets; do
resaved="rs_${ruleset}_resaved"
resaved_path="${tmpdir}/${resaved}"
reresaved="resaved_rs_${ruleset}"
reresaved_path="${tmpdir}/${reresaved}"
echo "Loading $ruleset and saving it as $resaved"
@abs_top_builddir@/fcruleup -F -c -r $ruleset \
--output "$resaved_path" \
|| exit 1
echo "Trying to load $ruleset saved as $resaved"
FREECIV_DATA_PATH=$tmpdir \
@abs_top_builddir@/tests/rs_test_res/ruleset_loads.sh "$resaved" \
|| exit 1
echo "Checking ruleset saving stability for $ruleset"
echo "Resaving resaved $ruleset"
FREECIV_DATA_PATH=$tmpdir @abs_top_builddir@/fcruleup -F -c -r "$resaved" \
--output "$reresaved_path" \
|| exit 1
if [ ! -d "$reresaved_path" ] ; then
echo "Missing $reresaved_path means that resaving must have failed."
exit 1
fi
result="`diff -u \"${resaved_path}\" \"${reresaved_path}\"`"
if test "${result}" != "" ; then
echo "${result}"
echo "Unstable ruleset saving."
exit 1
fi
done
if test "$KEEP_RESULT_IN_DIR" = "" ; then
# Should not be kept
rm -rf "${tmpdir}"
fi
echo "No resaving problems detected."
exit 0
tests/rulesets_upgrade.sh.in
#!/usr/bin/env bash
#/***********************************************************************
# Freeciv - Copyright (C) 2017-2023
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#***********************************************************************/
# rulesets_upgrade.sh
# Exits with 0 when each ruleset specified in upgrade_ruleset_list.txt can
# be saved using ruleup.
# Exits with 1 if not.
# If KEEP_RESULT_IN_DIR is set to a folder the saved result will be kept
# there for later inspection even if nothing fails.
FREECIV_DATA_PATH="@abs_top_srcdir@/tests/rs_test_res/upgrade_rulesets:$FREECIV_DATA_PATH" \
./tests/rulesets_save.sh `cat @abs_top_srcdir@/tests/rs_test_res/upgrade_ruleset_list.txt`
    (1-1/1)