Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
e84e7bd5
Commit
e84e7bd5
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Convert Homebrew::Cleanup test to spec.
parent
f06898a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/test/cleanup_spec.rb
+130
-0
130 additions, 0 deletions
Library/Homebrew/test/cleanup_spec.rb
Library/Homebrew/test/cleanup_test.rb
+0
-96
0 additions, 96 deletions
Library/Homebrew/test/cleanup_test.rb
with
130 additions
and
96 deletions
Library/Homebrew/test/cleanup_spec.rb
0 → 100644
+
130
−
0
View file @
e84e7bd5
require
"test/support/fixtures/testball"
require
"cleanup"
require
"fileutils"
require
"pathname"
describe
Homebrew
::
Cleanup
do
let
(
:ds_store
)
{
Pathname
.
new
(
"
#{
HOMEBREW_PREFIX
}
/Library/.DS_Store"
)
}
around
(
:each
)
do
|
example
|
begin
FileUtils
.
touch
ds_store
example
.
run
ensure
FileUtils
.
rm_f
ds_store
end
end
describe
"::cleanup"
do
it
"removes .DS_Store files"
do
shutup
do
described_class
.
cleanup
end
expect
(
ds_store
).
not_to
exist
end
it
"doesn't remove anything if `--dry-run` is specified"
do
ARGV
<<
"--dry-run"
shutup
do
described_class
.
cleanup
end
expect
(
ds_store
).
to
exist
end
end
specify
"::cleanup_formula"
do
f1
=
Class
.
new
(
Testball
)
do
version
"1.0"
end
.
new
f2
=
Class
.
new
(
Testball
)
do
version
"0.2"
version_scheme
1
end
.
new
f3
=
Class
.
new
(
Testball
)
do
version
"0.3"
version_scheme
1
end
.
new
f4
=
Class
.
new
(
Testball
)
do
version
"0.1"
version_scheme
2
end
.
new
shutup
do
[
f1
,
f2
,
f3
,
f4
].
each
do
|
f
|
f
.
brew
do
f
.
install
end
Tab
.
create
(
f
,
DevelopmentTools
.
default_compiler
,
:libcxx
).
write
end
end
expect
(
f1
).
to
be_installed
expect
(
f2
).
to
be_installed
expect
(
f3
).
to
be_installed
expect
(
f4
).
to
be_installed
shutup
do
described_class
.
cleanup_formula
f3
end
expect
(
f1
).
not_to
be_installed
expect
(
f2
).
not_to
be_installed
expect
(
f3
).
to
be_installed
expect
(
f4
).
to
be_installed
end
specify
"::cleanup_logs"
do
path
=
(
HOMEBREW_LOGS
/
"delete_me"
)
path
.
mkpath
ARGV
<<
"--prune=all"
shutup
do
described_class
.
cleanup_logs
end
expect
(
path
).
not_to
exist
end
describe
"::cleanup_cache"
do
it
"cleans up incomplete downloads"
do
incomplete
=
(
HOMEBREW_CACHE
/
"something.incomplete"
)
incomplete
.
mkpath
shutup
do
described_class
.
cleanup_cache
end
expect
(
incomplete
).
not_to
exist
end
it
"cleans up 'java_cache'"
do
java_cache
=
(
HOMEBREW_CACHE
/
"java_cache"
)
java_cache
.
mkpath
shutup
do
described_class
.
cleanup_cache
end
expect
(
java_cache
).
not_to
exist
end
it
"cleans up 'npm_cache'"
do
npm_cache
=
(
HOMEBREW_CACHE
/
"npm_cache"
)
npm_cache
.
mkpath
shutup
do
described_class
.
cleanup_cache
end
expect
(
npm_cache
).
not_to
exist
end
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/cleanup_test.rb
deleted
100644 → 0
+
0
−
96
View file @
f06898a4
require
"testing_env"
require
"test/support/fixtures/testball"
require
"cleanup"
require
"fileutils"
require
"pathname"
require
"testing_env"
class
CleanupTests
<
Homebrew
::
TestCase
def
setup
super
@ds_store
=
Pathname
.
new
"
#{
HOMEBREW_PREFIX
}
/Library/.DS_Store"
FileUtils
.
touch
@ds_store
end
def
teardown
FileUtils
.
rm_f
@ds_store
super
end
def
test_cleanup
shutup
{
Homebrew
::
Cleanup
.
cleanup
}
refute_predicate
@ds_store
,
:exist?
end
def
test_cleanup_dry_run
ARGV
<<
"--dry-run"
shutup
{
Homebrew
::
Cleanup
.
cleanup
}
assert_predicate
@ds_store
,
:exist?
end
def
test_cleanup_formula
f1
=
Class
.
new
(
Testball
)
do
version
"1.0"
end
.
new
f2
=
Class
.
new
(
Testball
)
do
version
"0.2"
version_scheme
1
end
.
new
f3
=
Class
.
new
(
Testball
)
do
version
"0.3"
version_scheme
1
end
.
new
f4
=
Class
.
new
(
Testball
)
do
version
"0.1"
version_scheme
2
end
.
new
shutup
do
[
f1
,
f2
,
f3
,
f4
].
each
do
|
f
|
f
.
brew
{
f
.
install
}
Tab
.
create
(
f
,
DevelopmentTools
.
default_compiler
,
:libcxx
).
write
end
end
assert_predicate
f1
,
:installed?
assert_predicate
f2
,
:installed?
assert_predicate
f3
,
:installed?
assert_predicate
f4
,
:installed?
shutup
{
Homebrew
::
Cleanup
.
cleanup_formula
f3
}
refute_predicate
f1
,
:installed?
refute_predicate
f2
,
:installed?
assert_predicate
f3
,
:installed?
assert_predicate
f4
,
:installed?
end
def
test_cleanup_logs
path
=
(
HOMEBREW_LOGS
/
"delete_me"
)
path
.
mkpath
ARGV
<<
"--prune=all"
shutup
{
Homebrew
::
Cleanup
.
cleanup_logs
}
refute_predicate
path
,
:exist?
end
def
test_cleanup_cache_incomplete_downloads
incomplete
=
(
HOMEBREW_CACHE
/
"something.incomplete"
)
incomplete
.
mkpath
shutup
{
Homebrew
::
Cleanup
.
cleanup_cache
}
refute_predicate
incomplete
,
:exist?
end
def
test_cleanup_cache_java_cache
java_cache
=
(
HOMEBREW_CACHE
/
"java_cache"
)
java_cache
.
mkpath
shutup
{
Homebrew
::
Cleanup
.
cleanup_cache
}
refute_predicate
java_cache
,
:exist?
end
def
test_cleanup_cache_npm_cache
npm_cache
=
(
HOMEBREW_CACHE
/
"npm_cache"
)
npm_cache
.
mkpath
shutup
{
Homebrew
::
Cleanup
.
cleanup_cache
}
refute_predicate
npm_cache
,
:exist?
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment