From dfd9a7d9ad8be7b467f2203ccaa7b3e8ccb91f4a Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 16 Sep 2020 23:49:23 +0100 Subject: tests: Clear out $DATADIR after every test Some tests have a teardown script that removes their temporary files, but most do not. To avoid interference or dependencies between tests, use a global teardown script that removes almost everything in $DATADIR. It excludes git-upstream, which is intentionally set up once and read by multiple tests. --- tests/git-backup-on-error-multiple-backups.teardown | 21 --------------------- ...rror-single-backup-is-removed-if-exists.teardown | 21 --------------------- tests/git-backup-on-error-single-backup.teardown | 21 --------------------- tests/hg-incremental.teardown | 21 --------------------- tests/hg-single-commit.teardown | 21 --------------------- tests/hg-unnamed-head.teardown | 21 --------------------- tests/migrate-oldstyle-repos.teardown | 21 --------------------- tests/repo-update-count.teardown | 21 --------------------- tests/teardown | 7 +++++++ 9 files changed, 7 insertions(+), 168 deletions(-) delete mode 100755 tests/git-backup-on-error-multiple-backups.teardown delete mode 100755 tests/git-backup-on-error-single-backup-is-removed-if-exists.teardown delete mode 100755 tests/git-backup-on-error-single-backup.teardown delete mode 100755 tests/hg-incremental.teardown delete mode 100755 tests/hg-single-commit.teardown delete mode 100755 tests/hg-unnamed-head.teardown delete mode 100755 tests/migrate-oldstyle-repos.teardown delete mode 100755 tests/repo-update-count.teardown create mode 100755 tests/teardown diff --git a/tests/git-backup-on-error-multiple-backups.teardown b/tests/git-backup-on-error-multiple-backups.teardown deleted file mode 100755 index 8b5bef3..0000000 --- a/tests/git-backup-on-error-multiple-backups.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Tests when a git mirror fails that it keeps the backups around -# -# Copyright (C) 2012-2013 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -r "$DATADIR/git-backup-test-repo.log" "$DATADIR/work-dir" diff --git a/tests/git-backup-on-error-single-backup-is-removed-if-exists.teardown b/tests/git-backup-on-error-single-backup-is-removed-if-exists.teardown deleted file mode 100755 index 8b5bef3..0000000 --- a/tests/git-backup-on-error-single-backup-is-removed-if-exists.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Tests when a git mirror fails that it keeps the backups around -# -# Copyright (C) 2012-2013 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -r "$DATADIR/git-backup-test-repo.log" "$DATADIR/work-dir" diff --git a/tests/git-backup-on-error-single-backup.teardown b/tests/git-backup-on-error-single-backup.teardown deleted file mode 100755 index 8b5bef3..0000000 --- a/tests/git-backup-on-error-single-backup.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Tests when a git mirror fails that it keeps the backups around -# -# Copyright (C) 2012-2013 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -r "$DATADIR/git-backup-test-repo.log" "$DATADIR/work-dir" diff --git a/tests/hg-incremental.teardown b/tests/hg-incremental.teardown deleted file mode 100755 index 409c26b..0000000 --- a/tests/hg-incremental.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# Tests incremental conversion of a simple hg repository to git. -# -# Copyright (C) 2020 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -rf "$DATADIR/hg-test-repo" "$DATADIR/hg-test-repo.lorry" "$DATADIR/work-dir" diff --git a/tests/hg-single-commit.teardown b/tests/hg-single-commit.teardown deleted file mode 100755 index 5a6aa57..0000000 --- a/tests/hg-single-commit.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# Tests converting a simple hg repository to git. -# -# Copyright (C) 2020 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -rf "$DATADIR/hg-test-repo" "$DATADIR/hg-test-repo.lorry" "$DATADIR/work-dir" diff --git a/tests/hg-unnamed-head.teardown b/tests/hg-unnamed-head.teardown deleted file mode 100755 index 8b8cee1..0000000 --- a/tests/hg-unnamed-head.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# Regression test for https://gitlab.com/CodethinkLabs/lorry/lorry/-/issues/7 -# -# Copyright (C) 2020 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -rf "$DATADIR/hg-test-repo" "$DATADIR/hg-test-repo.lorry" "$DATADIR/work-dir" diff --git a/tests/migrate-oldstyle-repos.teardown b/tests/migrate-oldstyle-repos.teardown deleted file mode 100755 index 19d1cb1..0000000 --- a/tests/migrate-oldstyle-repos.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Tests migration of old-style working repositories -# -# Copyright (C) 2020 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -r "$DATADIR/migrate-test-repo.log" "$DATADIR/work-dir" diff --git a/tests/repo-update-count.teardown b/tests/repo-update-count.teardown deleted file mode 100755 index b400abf..0000000 --- a/tests/repo-update-count.teardown +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Tests update counts in working repositories -# -# Copyright (C) 2020 Codethink Limited -# -# 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; version 2 of the License. -# -# 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. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -rm -r "$DATADIR/update-count-test-repo.log" "$DATADIR/work-dir" diff --git a/tests/teardown b/tests/teardown new file mode 100755 index 0000000..c821266 --- /dev/null +++ b/tests/teardown @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +# Delete everything under $DATADIR except git-upstream +find "$DATADIR" -mindepth 1 -maxdepth 1 \! -path "$DATADIR/git-upstream" \ + -exec rm -rf {} \+ -- cgit v1.2.1