From 719991b78af9ac6915179209771be4138065e182 Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Wed, 21 Jun 2023 16:18:22 +0200 Subject: Use a cargo feature to allow disabling docker tests in CI Ideally these tests would run in CI, but that would require docker in docker, since CI runs its tests in docker. --- .woodpecker.yml | 2 +- CHANGELOG.md | 6 ++++++ Cargo.toml | 4 ++++ tests/server_shell.rs | 7 +++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index f3b0e5c..cee339a 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -4,4 +4,4 @@ pipeline: environment: [CARGO_TERM_COLOR=always] commands: - rustup default stable - - cargo test + - cargo test --no-default-features diff --git a/CHANGELOG.md b/CHANGELOG.md index cd6ea83..598ff2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added feature flag "docker_tests". This only affects which tests are run by + default, so that the CI environment can skip tests that require running + docker. + ## [0.1.1] - 2023-05-10 ### Changed diff --git a/Cargo.toml b/Cargo.toml index 02113e2..8bcad68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,10 @@ once_cell = "1.17.1" tempfile = "3.4.0" rexpect = "0.5.0" +[features] +docker_tests = [] +default = ["docker_tests"] + [profile.dev.package."*"] opt-level = 3 # incremental compile is rarely useful for dependencies since they change diff --git a/tests/server_shell.rs b/tests/server_shell.rs index 22f3d3b..806f901 100644 --- a/tests/server_shell.rs +++ b/tests/server_shell.rs @@ -164,6 +164,7 @@ fn make_new_shared_repo(c: &TestContext, group: &str, repo_name: &str) -> Result } #[test] +#[cfg_attr(not(feature = "docker_tests"), ignore)] fn shows_a_prompt() -> Result<()> { let c = spawn_ssh_server()?; connect_to_ssh_server_interactively(&c)?; @@ -237,6 +238,7 @@ fn commit_dummy_content(c: &TestContext, repo_name: &str) -> Result<()> { } #[test] +#[cfg_attr(not(feature = "docker_tests"), ignore)] fn git_clone_works_with_an_empty_repo() -> Result<()> { let c = spawn_ssh_server()?; let repo_name = "my-new-clonable-repo"; @@ -247,6 +249,7 @@ fn git_clone_works_with_an_empty_repo() -> Result<()> { } #[test] +#[cfg_attr(not(feature = "docker_tests"), ignore)] fn git_push_works() -> Result<()> { let c = spawn_ssh_server()?; let repo_name = "my-new-pushable-repo"; @@ -259,6 +262,7 @@ fn git_push_works() -> Result<()> { } #[test] +#[cfg_attr(not(feature = "docker_tests"), ignore)] fn git_clone_works_with_an_empty_shared_repo() -> Result<()> { let c = spawn_ssh_server()?; let repo_name = "my-new-clonable-repo"; @@ -270,6 +274,7 @@ fn git_clone_works_with_an_empty_shared_repo() -> Result<()> { } #[test] +#[cfg_attr(not(feature = "docker_tests"), ignore)] fn git_push_works_with_shared_repo() -> Result<()> { let c = spawn_ssh_server()?; let repo_name = "my-new-pushable-repo"; @@ -283,6 +288,7 @@ fn git_push_works_with_shared_repo() -> Result<()> { } #[test] +#[cfg_attr(not(feature = "docker_tests"), ignore)] fn git_clone_can_not_target_repo_outside_allowed_paths() -> Result<()> { fn test_git_clone_unallowed_path(repo_name: &str) -> Result<()> { let c = spawn_ssh_server()?; @@ -319,6 +325,7 @@ fn init_local_git_dir(c: &TestContext, repo_name: &str) { } #[test] +#[cfg_attr(not(feature = "docker_tests"), ignore)] fn git_push_can_not_target_repo_outside_allowed_paths() -> Result<()> { fn test_push_to_unallowed_path(repo_name: &str) -> Result<()> { let c = spawn_ssh_server()?; -- cgit v1.2.3