aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cmd/prune_spec.rb
blob: c5a9df70c5d0689483421fa5e68a78b421d4bd9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
describe "brew prune", :integration_test do
  it "removes empty directories and broken symlinks" do
    share = (HOMEBREW_PREFIX/"share")

    (share/"pruneable/directory/here").mkpath
    (share/"notpruneable/file").write "I'm here"
    FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink"

    expect { brew "prune", "--dry-run" }
      .to output(%r{Would remove \(empty directory\): .*/pruneable/directory/here}).to_stdout
      .and not_to_output.to_stderr
      .and be_a_success

    expect { brew "prune" }
      .to output(/Pruned 1 symbolic links and 3 directories/).to_stdout
      .and not_to_output.to_stderr
      .and be_a_success

    expect(share/"pruneable").not_to be_a_directory
    expect(share/"notpruneable").to be_a_directory
    expect(share/"pruneable_symlink").not_to be_a_symlink

    expect { brew "prune", "--verbose" }
      .to output(/Nothing pruned/).to_stdout
      .and not_to_output.to_stderr
      .and be_a_success
  end
end