Skip to content

Commit

Permalink
tarball: allow choosing the compression formats to output
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Dec 10, 2020
1 parent 88e76e1 commit 512629a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fn tarball(matches: &ArgMatches<'_>) -> Result<()> {
"input" => input,
"output" => output,
"work-dir" => work_dir,
"compression-formats" => compression_formats,
});

tarballer.run().context("failed to generate tarballs")?;
Expand Down
5 changes: 5 additions & 0 deletions src/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,9 @@ subcommands:
long: work-dir
takes_value: true
value_name: DIR
- compression-formats:
help: Comma-separated list of compression formats to use
long: compression-formats
takes_value: true
value_name: FORMAT

36 changes: 36 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,42 @@ combine_compression_formats_error() {
}
runtest combine_compression_formats_error

tarball_compression_formats_one() {
try cp -r "${TEST_DIR}/image1" "${WORK_DIR}/image"
try sh "$S/make-tarballs.sh" \
--input="${WORK_DIR}/image" \
--work-dir="${WORK_DIR}" \
--output="${OUT_DIR}/rustc" \
--compression-formats="xz"

try test ! -e "${OUT_DIR}/rustc.tar.gz"
try test -e "${OUT_DIR}/rustc.tar.xz"
}
runtest tarball_compression_formats_one

tarball_compression_formats_multiple() {
try cp -r "${TEST_DIR}/image1" "${WORK_DIR}/image"
try sh "$S/make-tarballs.sh" \
--input="${WORK_DIR}/image" \
--work-dir="${WORK_DIR}" \
--output="${OUT_DIR}/rustc" \
--compression-formats="xz,gz"

try test -e "${OUT_DIR}/rustc.tar.gz"
try test -e "${OUT_DIR}/rustc.tar.xz"
}
runtest tarball_compression_formats_multiple

tarball_compression_formats_error() {
try cp -r "${TEST_DIR}/image1" "${WORK_DIR}/image"
expect_fail sh "$S/make-tarballs.sh" \
--input="${WORK_DIR}/image" \
--work-dir="${WORK_DIR}" \
--output="${OUT_DIR}/rustc" \
--compression-formats="xz,foobar"
}
runtest tarball_compression_formats_error

echo
echo "TOTAL SUCCESS!"
echo

0 comments on commit 512629a

Please sign in to comment.