Skip to content

Commit

Permalink
Do not rely on local repo having test branches.
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es committed Dec 13, 2023
1 parent cc55867 commit c815f6b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create local branches for tests
run: |
for branch in test-root test-module-{a,b,c}; do
git branch --track "$branch" "origin/$branch"
done
- name: Build
run: cargo +stable build --verbose
- name: Run tests
Expand All @@ -24,11 +19,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create local branches for tests
run: |
for branch in test-root test-module-{a,b,c}; do
git branch --track "$branch" "origin/$branch"
done
- name: Build
run: cargo +nightly build --verbose
- name: Run tests
Expand Down
40 changes: 34 additions & 6 deletions git-version/tests/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,55 @@ fn test_in_external_clone() {
let target_dir = target_dir.join("tests_target");

let_assert!(Ok(result) = std::process::Command::new("git")
.arg("-c")
.arg("protocol.file.allow=always")
.arg("clone")
.arg("--quiet")
.arg("--recurse-submodules")
.arg("-b")
.arg("test-root")
.arg((lib_dir).join(".."))
.arg(tempdir.path())
.status()
);
assert!(result.success(), "git clone: {result}");

let_assert!(Ok(result) = std::process::Command::new("git")
.current_dir(&tempdir)
.arg("-c")
.arg("protocol.file.allow=always")
.arg("fetch")
.arg("--quiet")
.arg("origin")
.arg("+refs/remotes/origin/test-*:refs/heads/test-*")
.status()
);
assert!(result.success(), "git fetch: {result}");

let_assert!(Ok(result) = std::process::Command::new("git")
.current_dir(&tempdir)
.arg("switch")
.arg("--quiet")
.arg("test-root")
.status()
);
assert!(result.success(), "git fetch: {result}");

let_assert!(Ok(result) = std::process::Command::new("git")
.current_dir(&tempdir)
.arg("-c")
.arg("protocol.file.allow=always")
.arg("submodule")
.arg("--quiet")
.arg("update")
.arg("--init")
.status()
);
assert!(result.success(), "git submodule update --init: {result}");

let_assert!(Ok(result) = std::process::Command::new("cargo")
.current_dir(&tempdir)
.arg("add")
.arg("--path")
.arg(&(lib_dir))
.status()
);
assert!(result.success(), "cargo test: {result}");
assert!(result.success(), "cargo add: {result}");

let_assert!(Ok(result) = std::process::Command::new("cargo")
.current_dir(&tempdir)
Expand Down

0 comments on commit c815f6b

Please sign in to comment.