Skip to content

Commit

Permalink
Add output_match_clean_pkg_install().
Browse files Browse the repository at this point in the history
Avoids duplication of this common check across tests.
  • Loading branch information
jperkin committed Jun 15, 2023
1 parent bbb3e8b commit 6075005
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
8 changes: 2 additions & 6 deletions suite/autoremove.bats
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ teardown_file()
run pkgin -y fug
[ ${status} -eq 0 ]

output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9]"
output_not_match "pkg_install .*errors: [1-9]"
output_match_clean_pkg_install

# pkgin 22.9.0 has a bug where packages are not correctly marked as
# keep, and keep/unkeep do not work, so we need to do it manually to
Expand Down Expand Up @@ -153,9 +151,7 @@ teardown_file()

output_match "1 package.* to be autoremoved"
output_match "removing depend-1.0"
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9]"
output_not_match "pkg_install .*errors: [1-9]"
output_match_clean_pkg_install
fi
}

Expand Down
8 changes: 2 additions & 6 deletions suite/break-depends.bats
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ teardown_file()

output_match "7 package.* to.* install"
output_match "marking top-1.0 as non auto"
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9]"
output_not_match "pkg_install .*errors: [1-9]"
output_match_clean_pkg_install
}

@test "${SUITE} switch repository" {
Expand Down Expand Up @@ -214,9 +212,7 @@ teardown_file()
else
[ ${status} -eq 0 ]
output_not_match "package.* to.* remove"
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9]"
output_not_match "pkg_install .*errors: [1-9]"
output_match_clean_pkg_install
fi

}
Expand Down
13 changes: 13 additions & 0 deletions suite/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,19 @@ file_match()
done < ${matchfile}
[ ${#lines[@]} -eq ${nl} ]
}
#
# Common output matches
#
output_match_clean_pkg_install()
{
#
# There are often multiple output lines so we need to check for both
# positive and negative matches.
#
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9]"
output_not_match "pkg_install .*errors: [1-9]"
}

#
# Skip tests unsuitable for the current release.
Expand Down
2 changes: 1 addition & 1 deletion suite/file-dl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ setup_file()
if [ ${PKGIN_VERSION} -lt 001101 -o ${PKGIN_VERSION} -eq 001600 ]; then
output_match "1 package.* to .* install"
output_match "installing download-ok-1.0"
output_match "pkg_install warnings: 0, errors: 0"
output_match "marking download-ok-1.0 as non auto-removable"
output_match_clean_pkg_install
else
file_match "download-install.regex"
fi
Expand Down
2 changes: 1 addition & 1 deletion suite/http-dl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ teardown_file()
if [ ${PKGIN_VERSION} -lt 001101 -o ${PKGIN_VERSION} -eq 001600 ]; then
output_match "1 package.* to .* install"
output_match "download-ok-1.0"
output_match "pkg_install warnings: 0, errors: 0"
output_match "marking download-ok-1.0 as non auto-removable"
output_match_clean_pkg_install
else
file_match "download-install.regex"
fi
Expand Down
4 changes: 2 additions & 2 deletions suite/install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ teardown_file()
${PKGIN_VERSION} -eq 001600 ]; then
output_match "1 package.* install"
output_match "installing preserve-1.0"
output_match "pkg_install warnings: 0, errors: 0"
output_match_clean_pkg_install
else
file_match "install-against-empty.regex"
fi
Expand Down Expand Up @@ -226,9 +226,9 @@ teardown_file()

if [ ${PKGIN_VERSION} -lt 001300 -o ${PKGIN_VERSION} -eq 001600 ]; then
output_match "4 packages .* install"
output_match "pkg_install warnings: 0, errors: 0"
output_match "marking pkgpath-1.0 as non auto-removable"
output_match "marking deptree-top-1.0 as non auto-removable"
output_match_clean_pkg_install
else
# Non-deterministic output ordering.
file_match -I "install-remaining.regex"
Expand Down
12 changes: 4 additions & 8 deletions suite/upgrade.bats
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,14 @@ teardown_file()
output_match "installing refresh-1.0..."
fi
output_match "installing upgrade-2.0..."
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9], errors: [1-9]"
output_match_clean_pkg_install
elif [ ${PKGIN_VERSION} -le 200501 ]; then
output_match "refreshing refresh-1.0..."
output_match "upgrading deptree-bottom-2.0..."
output_match "upgrading deptree-top-2.0..."
output_match "upgrading upgrade-2.0..."
output_match "installing deptree-middle-2.0..."
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9], errors: [1-9]"
output_match_clean_pkg_install
else
file_match "full-upgrade.regex"
fi
Expand Down Expand Up @@ -387,13 +385,11 @@ teardown_file()
output_match "1 package.* to be installed"
output_match "removing pkgpath-1.0..."
output_match "installing pkgpath-2.0..."
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9], errors: [1-9]"
output_match_clean_pkg_install
elif [ ${PKGIN_VERSION} -eq 001600 ]; then
output_match "1 package to upgrade"
output_match "upgrading pkgpath-2.0..."
output_match "pkg_install warnings: 0, errors: 0"
output_not_match "pkg_install warnings: [1-9], errors: [1-9]"
output_match_clean_pkg_install
else
file_match "install-pkgpath-upgrade.regex"
fi
Expand Down

0 comments on commit 6075005

Please sign in to comment.