public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jesus Checa Hidalgo <jchecahi@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/rust] main: Add regression test for Cargo SCP-like Git submodule URLs
Date: Fri, 19 Jun 2026 00:16:13 GMT	[thread overview]
Message-ID: <178182817349.1.12670839039526194136.tests-rust-cca2ad09efbe@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/rust
            Branch : main
            Commit : cca2ad09efbec0813316f3b21e77ee7c578e46d9
            Author : Jesus Checa Hidalgo <jchecahi@redhat.com>
            Date   : 2026-06-15T16:47:51+02:00
            Stats  : +155/-2 in 3 file(s)
            URL    : https://src.fedoraproject.org/tests/rust/c/cca2ad09efbec0813316f3b21e77ee7c578e46d9?branch=main

            Log:
            Add regression test for Cargo SCP-like Git submodule URLs

Add downstreamed version of upstream test git::dep_with_scp_like_submodule_url
to verify that Cargo correctly handles SCP-like URLs (git@host:path format) in
Git submodules and preserves them in error messages.

This is a regression test for https://github.com/rust-lang/cargo/pull/16727

The test is enabled on distributions with Rust >= 1.96.0.

Upstream reference:
https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs

---
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8b17cbf..a965ddd 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,7 +2,7 @@
 # See https://pre-commit.com/hooks.html for more hooks
 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v4.4.0
+    rev: v6.0.0
     hooks:
     - id: trailing-whitespace
     - id: end-of-file-fixer
@@ -10,6 +10,6 @@ repos:
       args: [--unsafe]
     - id: check-added-large-files
   - repo: https://github.com/teemtee/tmt.git
-    rev: "1.31.0"
+    rev: "1.75.0"
     hooks:
     - id: tmt-lint

diff --git a/tests/Regression/cargo-git-submodule-scp-url/main.fmf b/tests/Regression/cargo-git-submodule-scp-url/main.fmf
new file mode 100644
index 0000000..1f81f1b
--- /dev/null
+++ b/tests/Regression/cargo-git-submodule-scp-url/main.fmf
@@ -0,0 +1,31 @@
+summary: Test cargo handles SCP-like Git submodule URLs
+description: |
+  Downstreamed version of the upstream test git::dep_with_scp_like_submodule_url
+  https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs
+
+  This test verifies that Cargo correctly handles Git submodules with SCP-like
+  URLs (git@github.com:foo/bar.git format) and preserves the original URL format
+  in error messages.
+
+  This is a regression test for https://github.com/rust-lang/cargo/pull/16727
+
+  The test uses git-fetch-with-cli to enable SSH support via /usr/bin/git, which
+  works even on RHEL/CentOS where Cargo is built without libssh2 (rhbz#1732949).
+
+  The test is enabled on distributions with Rust >= 1.96.0.
+
+tier: 1
+require+:
+  - git
+adjust+:
+  - enabled: false
+    when: distro ~< rhel-8.10
+    continue: false
+
+  - enabled: false
+    when: distro ~< rhel-9.9
+    continue: false
+
+  - enabled: false
+    when: distro ~< rhel-10.3
+    continue: false

diff --git a/tests/Regression/cargo-git-submodule-scp-url/runtest.sh b/tests/Regression/cargo-git-submodule-scp-url/runtest.sh
new file mode 100755
index 0000000..b55259f
--- /dev/null
+++ b/tests/Regression/cargo-git-submodule-scp-url/runtest.sh
@@ -0,0 +1,122 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+#
+# Downstreamed adaptation of the upstream Cargo test:
+# git::dep_with_scp_like_submodule_url
+# https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs
+#
+# REGRESSION TEST for https://github.com/rust-lang/cargo/pull/16727
+#
+# This test verifies that Cargo correctly handles SCP-like URLs (git@host:path)
+# in git submodules and preserves them in error messages.
+#
+# The test uses --config net.git-fetch-with-cli=true to delegate Git operations
+# to /usr/bin/git, which has SSH support even on RHEL/CentOS where Cargo is built
+# without libssh2 (rhbz#1732949).
+#
+# Expected behavior WITH the PR #16727 fix (Rust >= 1.96.0):
+#   - Cargo accepts SCP-like URLs in .gitmodules
+#   - Attempts to fetch the submodule via /usr/bin/git (with SSH support)
+#   - On failure, shows: "failed to fetch submodule `submod` from git@github.com:foo/bar.git"
+#
+# Expected behavior WITHOUT the fix (Rust < 1.96.0):
+#   - Cargo rejects SCP-like URLs as invalid
+#   - Shows: "invalid url `git@github.com:foo/bar.git`: relative URL without a base"
+#   - This test will FAIL (expected for a regression test before the fix is applied)
+#
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+CRATE_NAME="foo"
+CRATE_VER="0.5.0"
+DEP1_NAME="dep1"
+DEP2_NAME="dep2"
+SCP_URL="git@github.com:foo/bar.git"
+
+rlJournalStart
+    rlPhaseStartSetup
+        declare tmp
+        rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
+        rlRun "pushd $tmp"
+
+        # Create dep2 git repository (will be used as submodule)
+        rlRun "mkdir $DEP2_NAME && cd $DEP2_NAME"
+        rlRun "git init"
+        rlRun "echo 'pub fn dep2() {}' > lib.rs"
+        rlRun "git add lib.rs"
+        rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Initial commit'"
+        rlRun "DEP2_PATH=\$(pwd)"
+        rlRun "cd .."
+
+        # Create dep1 git repository with Cargo.toml
+        rlRun "mkdir $DEP1_NAME && cd $DEP1_NAME"
+        rlRun "git init"
+        rlRun "mkdir src"
+        rlRun "echo 'pub fn dep() {}' > src/lib.rs"
+        cat > Cargo.toml <<EOF
+[package]
+name = "$DEP1_NAME"
+version = "$CRATE_VER"
+edition = "2015"
+EOF
+        rlRun "git add ."
+        rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Initial commit'"
+
+        # Manually add dep2 as submodule to avoid file:// protocol restrictions
+        # Use git -c to allow file:// protocol temporarily
+        rlRun "git -c protocol.file.allow=always submodule add \$DEP2_PATH submod"
+        rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Add submodule'"
+
+        # Change .gitmodules to use SCP-like URL
+        cat > .gitmodules <<EOF
+[submodule "submod"]
+	path = submod
+	url = $SCP_URL
+EOF
+        rlRun "git add .gitmodules"
+        rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Change to SCP URL'"
+
+        rlRun "DEP1_PATH=\$(pwd)"
+        rlRun "cd .."
+
+        # Create main project that depends on dep1
+        rlRun "mkdir $CRATE_NAME && cd $CRATE_NAME"
+        rlRun "mkdir src"
+        rlRun "touch src/lib.rs"
+
+        # Create Cargo.toml with proper variable expansion
+        rlRun "cat > Cargo.toml <<CARGO_EOF
+[package]
+name = \"$CRATE_NAME\"
+version = \"$CRATE_VER\"
+edition = \"2015\"
+
+[dependencies.$DEP1_NAME]
+git = \"file://\$DEP1_PATH\"
+CARGO_EOF
+"
+    rlPhaseEnd
+
+    rlPhaseStartTest
+        rlRun "set -o pipefail"
+
+        # Set GIT_SSH_COMMAND to match upstream test behavior
+        # This ensures Git attempts SSH connection (even though it will fail)
+        rlRun "export GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR'"
+
+        # Execute cargo fetch - should fail with exit code 101
+        # Let cargo invoke git cli, as in RHEL it doesn't have libssh2 support
+        rlRun "cargo --config net.git-fetch-with-cli=true fetch -v 2>&1 | tee output.log" 101
+
+        # Verify the exact error message that indicates PR #16727 is applied
+        # The test expects Cargo to:
+        # 1. Show it's updating the git submodule with the SCP URL
+        # 2. Fail with a specific message that includes the SCP URL
+        rlAssertGrep "git submodule.*$SCP_URL" output.log -Ei
+        rlAssertGrep "failed to fetch submodule.*submod.*from.*$SCP_URL" output.log -Ei
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        rlRun "popd"
+        rlRun "rm -rf $tmp" 0 "Remove tmp directory"
+    rlPhaseEnd
+rlJournalEnd

                 reply	other threads:[~2026-06-19  0:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178182817349.1.12670839039526194136.tests-rust-cca2ad09efbe@fedoraproject.org \
    --to=jchecahi@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox