-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract slow git tests to a separate rake task
- Loading branch information
Bits
committed
Apr 23, 2024
1 parent
3a7bc9b
commit c63e3cb
Showing
2 changed files
with
90 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,83 +105,6 @@ def with_custom_git_environment | |
it { is_expected.to eq("[email protected]:DataDog/datadog-ci-rb.git") } | ||
end | ||
|
||
describe ".git_commits" do | ||
subject { described_class.git_commits } | ||
|
||
it "returns a list of git commit sha (this test will fail if there are no commits to this library in the past month)" do | ||
expect(subject).to be_kind_of(Array) | ||
expect(subject).not_to be_empty | ||
expect(subject.first).to eq(described_class.git_commit_sha) | ||
end | ||
end | ||
|
||
describe ".git_commits_rev_list" do | ||
# skip for jruby for now - old git version DD docker image | ||
before { skip if PlatformHelpers.jruby? } | ||
|
||
let(:commits) { described_class.git_commits } | ||
let(:included_commits) { commits[0..1] } | ||
let(:excluded_commits) { commits[2..] } | ||
|
||
subject do | ||
described_class.git_commits_rev_list(included_commits: included_commits, excluded_commits: excluded_commits) | ||
end | ||
|
||
it "returns a list of commits that are reachable from included list but not reachable from excluded list" do | ||
expect(subject).to include(included_commits.join("\n")) | ||
end | ||
|
||
context "invalid commits" do | ||
let(:included_commits) { [" | echo \"boo\" "] } | ||
let(:excluded_commits) { [" | echo \"boo\" "] } | ||
|
||
it "returns nil" do | ||
expect(subject).to be_nil | ||
end | ||
end | ||
end | ||
|
||
describe ".git_generate_packfiles" do | ||
# skip for jruby for now - old git version DD docker image | ||
before { skip if PlatformHelpers.jruby? } | ||
|
||
let(:commits) { described_class.git_commits } | ||
let(:included_commits) { commits[0..1] } | ||
let(:excluded_commits) { commits[2..] } | ||
|
||
subject do | ||
described_class.git_generate_packfiles( | ||
included_commits: included_commits, | ||
excluded_commits: excluded_commits, | ||
path: tmpdir | ||
) | ||
end | ||
|
||
context "temporary directory" do | ||
let(:tmpdir) { Dir.mktmpdir } | ||
|
||
after do | ||
FileUtils.remove_entry(tmpdir) | ||
end | ||
|
||
it "generates packfiles in temp directory" do | ||
expect(subject).to match(/^\h{8}$/) | ||
packfiles = Dir.entries(tmpdir) - %w[. ..] | ||
expect(packfiles).not_to be_empty | ||
expect(packfiles).to all(match(/^\h{8}-\h{40}\.(pack|idx|rev)$/)) | ||
end | ||
end | ||
|
||
context "no such directory" do | ||
let(:tmpdir) { " | echo \"boo\"" } | ||
|
||
it "returns nil" do | ||
expect(subject).to be_nil | ||
expect(File.exist?(tmpdir)).to be_falsey | ||
end | ||
end | ||
end | ||
|
||
context "with git folder" do | ||
include_context "with git fixture", "gitdir_with_commit" | ||
|
||
|
@@ -382,6 +305,85 @@ def with_clone_git_dir | |
`cd #{tmpdir} && git clone file://#{origin_path} #{clone_folder_name}` | ||
end | ||
|
||
describe ".git_commits" do | ||
subject { with_clone_git_dir { described_class.git_commits } } | ||
|
||
it "returns a list of git commit sha" do | ||
expect(subject).to be_kind_of(Array) | ||
expect(subject).not_to be_empty | ||
expect(subject.first).to eq( | ||
with_clone_git_dir do | ||
described_class.git_commit_sha | ||
end | ||
) | ||
end | ||
end | ||
|
||
describe ".git_commits_rev_list" do | ||
let(:commits) { with_clone_git_dir { described_class.git_commits } } | ||
let(:included_commits) { commits[0..1] } | ||
let(:excluded_commits) { commits[2..] } | ||
|
||
subject do | ||
with_clone_git_dir do | ||
described_class.git_commits_rev_list(included_commits: included_commits, excluded_commits: excluded_commits) | ||
end | ||
end | ||
|
||
it "returns a list of commits that are reachable from included list but not reachable from excluded list" do | ||
expect(subject).to include(included_commits.join("\n")) | ||
expect(subject).not_to include(excluded_commits.first) | ||
end | ||
|
||
context "invalid commits" do | ||
let(:included_commits) { [" | echo \"boo\" "] } | ||
let(:excluded_commits) { [" | echo \"boo\" "] } | ||
|
||
it "returns nil" do | ||
expect(subject).to be_nil | ||
end | ||
end | ||
end | ||
|
||
describe ".git_generate_packfiles" do | ||
let(:commits) { with_clone_git_dir { described_class.git_commits } } | ||
let(:included_commits) { commits[0..1] } | ||
let(:excluded_commits) { commits[2..] } | ||
|
||
subject do | ||
with_clone_git_dir do | ||
described_class.git_generate_packfiles( | ||
included_commits: included_commits, | ||
excluded_commits: excluded_commits, | ||
path: packfiles_dir | ||
) | ||
end | ||
end | ||
|
||
context "temporary directory" do | ||
let(:packfiles_dir) { File.join(tmpdir, "packfiles") } | ||
before do | ||
`mkdir -p #{packfiles_dir}` | ||
end | ||
|
||
it "generates packfiles in temp directory" do | ||
expect(subject).to match(/^\h{8}$/) | ||
packfiles = Dir.entries(packfiles_dir) - %w[. ..] | ||
expect(packfiles).not_to be_empty | ||
expect(packfiles).to all(match(/^\h{8}-\h{40}\.(pack|idx|rev)$/)) | ||
end | ||
end | ||
|
||
context "no such directory" do | ||
let(:packfiles_dir) { " | echo \"boo\"" } | ||
|
||
it "returns nil" do | ||
expect(subject).to be_nil | ||
expect(File.exist?(packfiles_dir)).to be_falsey | ||
end | ||
end | ||
end | ||
|
||
describe ".git_shallow_clone?" do | ||
subject do | ||
with_clone_git_dir { described_class.git_shallow_clone? } | ||
|