2013-01-05 18:47:50 -05:00
|
|
|
# GNU Guix --- Functional package management for GNU
|
2024-05-13 08:53:04 -04:00
|
|
|
# Copyright © 2012, 2015-2016, 2024 Ludovic Courtès <ludo@gnu.org>
|
2012-11-07 18:13:25 -05:00
|
|
|
#
|
2013-01-05 18:47:50 -05:00
|
|
|
# This file is part of GNU Guix.
|
2012-11-07 18:13:25 -05:00
|
|
|
#
|
2013-01-05 18:47:50 -05:00
|
|
|
# GNU Guix is free software; you can redistribute it and/or modify it
|
2012-11-07 18:13:25 -05:00
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
# your option) any later version.
|
|
|
|
#
|
2013-01-05 18:47:50 -05:00
|
|
|
# GNU Guix is distributed in the hope that it will be useful, but
|
2012-11-07 18:13:25 -05:00
|
|
|
# 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
|
2013-01-05 18:47:50 -05:00
|
|
|
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
2012-11-07 18:13:25 -05:00
|
|
|
|
2024-01-22 05:32:55 -05:00
|
|
|
# Define some files/folders needed for the tests.
|
|
|
|
output="t-download-$$"
|
|
|
|
test_git_repo="$(mktemp -d)"
|
|
|
|
output_dir="t-archive-dir-$$"
|
|
|
|
trap 'rm -rf "$test_git_repo" ; rm -f "$output" ; rm -rf "$output_dir"' EXIT
|
|
|
|
|
2012-11-07 18:13:25 -05:00
|
|
|
#
|
Replace individual scripts with master 'guix' script.
* scripts/guix.in: New script.
* Makefile.am (bin_SCRIPTS): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
(MODULES): Add 'guix/scripts/build.scm', 'guix/scripts/download.scm',
'guix/scripts/import.scm', 'guix/scripts/package.scm', and
'guix/scripts/gc.scm'.
* configure.ac (AC_CONFIG_FILES): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Remove shell script boilerplate. Move to guix-COMMAND.in
to guix/scripts/COMMAND.scm. Rename module from (guix-COMMAND) to
(guix scripts COMMAND). Change "guix-COMMAND" to "guix COMMAND" in
usage help string.
* pre-inst-env.in: Add "@abs_top_builddir@/scripts" to the front of $PATH.
Export $GUIX_UNINSTALLED.
* tests/guix-build.sh, tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-gc.sh, tests/guix-package.sh: Use "guix COMMAND" instead of
"guix-COMMAND".
* doc/guix.texi: Replace all occurrences of "guix-COMMAND" with
"guix COMMAND".
* po/POTFILES.in: Update.
2013-02-14 04:15:25 -05:00
|
|
|
# Test the `guix download' command-line utility.
|
2012-11-07 18:13:25 -05:00
|
|
|
#
|
|
|
|
|
Replace individual scripts with master 'guix' script.
* scripts/guix.in: New script.
* Makefile.am (bin_SCRIPTS): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
(MODULES): Add 'guix/scripts/build.scm', 'guix/scripts/download.scm',
'guix/scripts/import.scm', 'guix/scripts/package.scm', and
'guix/scripts/gc.scm'.
* configure.ac (AC_CONFIG_FILES): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Remove shell script boilerplate. Move to guix-COMMAND.in
to guix/scripts/COMMAND.scm. Rename module from (guix-COMMAND) to
(guix scripts COMMAND). Change "guix-COMMAND" to "guix COMMAND" in
usage help string.
* pre-inst-env.in: Add "@abs_top_builddir@/scripts" to the front of $PATH.
Export $GUIX_UNINSTALLED.
* tests/guix-build.sh, tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-gc.sh, tests/guix-package.sh: Use "guix COMMAND" instead of
"guix-COMMAND".
* doc/guix.texi: Replace all occurrences of "guix-COMMAND" with
"guix COMMAND".
* po/POTFILES.in: Update.
2013-02-14 04:15:25 -05:00
|
|
|
guix download --version
|
2012-11-07 18:13:25 -05:00
|
|
|
|
|
|
|
# Make sure it fails here.
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 01:11:27 -04:00
|
|
|
guix download http://does.not/exist && false
|
2012-11-13 16:13:11 -05:00
|
|
|
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 01:11:27 -04:00
|
|
|
guix download unknown://some/where && false
|
2012-11-13 16:13:11 -05:00
|
|
|
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 01:11:27 -04:00
|
|
|
guix download /does-not-exist && false
|
2012-11-13 16:57:50 -05:00
|
|
|
|
|
|
|
# This one should succeed.
|
Replace individual scripts with master 'guix' script.
* scripts/guix.in: New script.
* Makefile.am (bin_SCRIPTS): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
(MODULES): Add 'guix/scripts/build.scm', 'guix/scripts/download.scm',
'guix/scripts/import.scm', 'guix/scripts/package.scm', and
'guix/scripts/gc.scm'.
* configure.ac (AC_CONFIG_FILES): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Remove shell script boilerplate. Move to guix-COMMAND.in
to guix/scripts/COMMAND.scm. Rename module from (guix-COMMAND) to
(guix scripts COMMAND). Change "guix-COMMAND" to "guix COMMAND" in
usage help string.
* pre-inst-env.in: Add "@abs_top_builddir@/scripts" to the front of $PATH.
Export $GUIX_UNINSTALLED.
* tests/guix-build.sh, tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-gc.sh, tests/guix-package.sh: Use "guix COMMAND" instead of
"guix-COMMAND".
* doc/guix.texi: Replace all occurrences of "guix-COMMAND" with
"guix COMMAND".
* po/POTFILES.in: Update.
2013-02-14 04:15:25 -05:00
|
|
|
guix download "file://$abs_top_srcdir/README"
|
2015-11-23 11:37:29 -05:00
|
|
|
|
2017-08-19 08:41:44 -04:00
|
|
|
# And this one, without the URI scheme.
|
|
|
|
guix download "$abs_top_srcdir/README"
|
|
|
|
|
2016-10-28 19:16:24 -04:00
|
|
|
# This one too, even if it cannot talk to the daemon.
|
|
|
|
GUIX_DAEMON_SOCKET="/nowhere" guix download -o "$output" \
|
|
|
|
"file://$abs_top_srcdir/README"
|
|
|
|
cmp "$output" "$abs_top_srcdir/README"
|
|
|
|
|
2015-11-23 11:37:29 -05:00
|
|
|
# This one should fail.
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 01:11:27 -04:00
|
|
|
guix download "file:///does-not-exist" "file://$abs_top_srcdir/README" && false
|
|
|
|
|
2024-01-22 05:32:55 -05:00
|
|
|
# Test git support with local repository.
|
|
|
|
# First, create a dummy git repo in the temporary directory.
|
|
|
|
(
|
2024-05-13 08:53:04 -04:00
|
|
|
# Avoid interference with user config.
|
|
|
|
GIT_CONFIG_GLOBAL=/dev/null
|
|
|
|
GIT_CONFIG_SYSTEM=/dev/null
|
|
|
|
export GIT_CONFIG_SYSTEM GIT_CONFIG_GLOBAL
|
|
|
|
|
2024-01-22 05:32:55 -05:00
|
|
|
cd $test_git_repo
|
|
|
|
git init
|
|
|
|
touch test
|
|
|
|
git config user.name "User"
|
|
|
|
git config user.email "user@domain"
|
|
|
|
git add test
|
|
|
|
git commit -m "Commit"
|
|
|
|
git tag -a -m "v1" v1
|
|
|
|
)
|
|
|
|
|
|
|
|
# Extract commit number.
|
|
|
|
commit=$((cd $test_git_repo && git log) | head -n 1 | cut -f2 -d' ')
|
|
|
|
|
|
|
|
# We expect that guix hash is working properly or at least that the output of
|
|
|
|
# 'guix download' is consistent with 'guix hash'.
|
|
|
|
expected_hash=$(guix hash -rx $test_git_repo)
|
|
|
|
|
|
|
|
# Test the different options
|
|
|
|
for option in "" "--commit=$commit" "--commit=v1" "--branch=master"
|
|
|
|
do
|
|
|
|
command_output="$(guix download --git $option "file://$test_git_repo")"
|
|
|
|
computed_hash="$(echo $command_output | cut -f2 -d' ')"
|
|
|
|
store_path="$(echo $command_output | cut -f1 -d' ')"
|
|
|
|
[ "$expected_hash" = "$computed_hash" ]
|
|
|
|
diff -r -x ".git" $test_git_repo $store_path
|
|
|
|
done
|
|
|
|
|
|
|
|
# Should fail.
|
|
|
|
guix download --git --branch=non_existent "file://$test_git_repo" && false
|
|
|
|
|
|
|
|
# Same but download to file instead of store.
|
|
|
|
guix download --git "file://$test_git_repo" -o $output_dir
|
|
|
|
diff -r -x ".git" $test_git_repo $output_dir
|
|
|
|
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 01:11:27 -04:00
|
|
|
exit 0
|