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
dbdd39b1
Commit
dbdd39b1
authored
8 years ago
by
Markus Reiter
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2213 from reitermarkus/spec-commands
Convert `brew commands` test to spec.
parents
f9e53e4b
125abd22
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/cmd/commands_spec.rb
+85
-0
85 additions, 0 deletions
Library/Homebrew/test/cmd/commands_spec.rb
Library/Homebrew/test/commands_test.rb
+0
-77
0 additions, 77 deletions
Library/Homebrew/test/commands_test.rb
with
85 additions
and
77 deletions
Library/Homebrew/test/cmd/commands_spec.rb
+
85
−
0
View file @
dbdd39b1
require
"cmd/command"
require
"cmd/commands"
require
"fileutils"
describe
"brew commands"
,
:integration_test
do
it
"prints a list of all available commands"
do
expect
{
brew
"commands"
}
...
...
@@ -5,3 +9,84 @@ describe "brew commands", :integration_test do
.
and
be_a_success
end
end
RSpec
.
shared_context
"custom internal commands"
do
let
(
:cmds
)
do
[
# internal commands
HOMEBREW_LIBRARY_PATH
/
"cmd/rbcmd.rb"
,
HOMEBREW_LIBRARY_PATH
/
"cmd/shcmd.sh"
,
# internal developer-commands
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/rbdevcmd.rb"
,
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/shdevcmd.sh"
,
]
end
around
(
:each
)
do
|
example
|
begin
cmds
.
each
do
|
f
|
FileUtils
.
touch
f
end
example
.
run
ensure
FileUtils
.
rm_f
cmds
end
end
end
describe
Homebrew
do
include_context
"custom internal commands"
specify
"::internal_commands"
do
cmds
=
described_class
.
internal_commands
expect
(
cmds
).
to
include
(
"rbcmd"
),
"Ruby commands files should be recognized"
expect
(
cmds
).
to
include
(
"shcmd"
),
"Shell commands files should be recognized"
expect
(
cmds
).
not_to
include
(
"rbdevcmd"
),
"Dev commands shouldn't be included"
end
specify
"::internal_developer_commands"
do
cmds
=
described_class
.
internal_developer_commands
expect
(
cmds
).
to
include
(
"rbdevcmd"
),
"Ruby commands files should be recognized"
expect
(
cmds
).
to
include
(
"shdevcmd"
),
"Shell commands files should be recognized"
expect
(
cmds
).
not_to
include
(
"rbcmd"
),
"Non-dev commands shouldn't be included"
end
specify
"::external_commands"
do
Dir
.
mktmpdir
do
|
dir
|
%w[brew-t1 brew-t2.rb brew-t3.py]
.
each
do
|
file
|
path
=
"
#{
dir
}
/
#{
file
}
"
FileUtils
.
touch
path
FileUtils
.
chmod
0755
,
path
end
FileUtils
.
touch
"
#{
dir
}
/brew-t4"
ENV
[
"PATH"
]
+=
"
#{
File
::
PATH_SEPARATOR
}#{
dir
}
"
cmds
=
described_class
.
external_commands
expect
(
cmds
).
to
include
(
"t1"
),
"Executable files should be included"
expect
(
cmds
).
to
include
(
"t2"
),
"Executable Ruby files should be included"
expect
(
cmds
).
not_to
include
(
"t3"
),
"Executable files with a non Ruby extension shoudn't be included"
expect
(
cmds
).
not_to
include
(
"t4"
),
"Non-executable files shouldn't be included"
end
end
end
describe
Commands
do
include_context
"custom internal commands"
describe
"::path"
do
specify
"returns the path for an internal command"
do
expect
(
described_class
.
path
(
"rbcmd"
)).
to
eq
(
HOMEBREW_LIBRARY_PATH
/
"cmd/rbcmd.rb"
)
expect
(
described_class
.
path
(
"shcmd"
)).
to
eq
(
HOMEBREW_LIBRARY_PATH
/
"cmd/shcmd.sh"
)
expect
(
described_class
.
path
(
"idontexist1234"
)).
to
be
nil
end
specify
"returns the path for an internal developer-command"
do
expect
(
described_class
.
path
(
"rbdevcmd"
)).
to
eq
(
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/rbdevcmd.rb"
)
expect
(
described_class
.
path
(
"shdevcmd"
)).
to
eq
(
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/shdevcmd.sh"
)
end
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/commands_test.rb
deleted
100644 → 0
+
0
−
77
View file @
f9e53e4b
require
"testing_env"
require
"cmd/command"
require
"cmd/commands"
require
"fileutils"
require
"testing_env"
class
CommandsTests
<
Homebrew
::
TestCase
def
setup
super
@cmds
=
[
# internal commands
HOMEBREW_LIBRARY_PATH
/
"cmd/rbcmd.rb"
,
HOMEBREW_LIBRARY_PATH
/
"cmd/shcmd.sh"
,
# internal development commands
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/rbdevcmd.rb"
,
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/shdevcmd.sh"
,
]
@cmds
.
each
{
|
f
|
FileUtils
.
touch
f
}
end
def
teardown
@cmds
.
each
(
&
:unlink
)
super
end
def
test_internal_commands
cmds
=
Homebrew
.
internal_commands
assert
cmds
.
include?
(
"rbcmd"
),
"Ruby commands files should be recognized"
assert
cmds
.
include?
(
"shcmd"
),
"Shell commands files should be recognized"
refute
cmds
.
include?
(
"rbdevcmd"
),
"Dev commands shouldn't be included"
end
def
test_internal_developer_commands
cmds
=
Homebrew
.
internal_developer_commands
assert
cmds
.
include?
(
"rbdevcmd"
),
"Ruby commands files should be recognized"
assert
cmds
.
include?
(
"shdevcmd"
),
"Shell commands files should be recognized"
refute
cmds
.
include?
(
"rbcmd"
),
"Non-dev commands shouldn't be included"
end
def
test_external_commands
mktmpdir
do
|
dir
|
%w[brew-t1 brew-t2.rb brew-t3.py]
.
each
do
|
file
|
path
=
"
#{
dir
}
/
#{
file
}
"
FileUtils
.
touch
path
FileUtils
.
chmod
0755
,
path
end
FileUtils
.
touch
"
#{
dir
}
/brew-t4"
ENV
[
"PATH"
]
+=
"
#{
File
::
PATH_SEPARATOR
}#{
dir
}
"
cmds
=
Homebrew
.
external_commands
assert
cmds
.
include?
(
"t1"
),
"Executable files should be included"
assert
cmds
.
include?
(
"t2"
),
"Executable Ruby files should be included"
refute
cmds
.
include?
(
"t3"
),
"Executable files with a non Ruby extension shoudn't be included"
refute
cmds
.
include?
(
"t4"
),
"Non-executable files shouldn't be included"
end
end
def
test_internal_command_path
assert_equal
HOMEBREW_LIBRARY_PATH
/
"cmd/rbcmd.rb"
,
Commands
.
path
(
"rbcmd"
)
assert_equal
HOMEBREW_LIBRARY_PATH
/
"cmd/shcmd.sh"
,
Commands
.
path
(
"shcmd"
)
assert_nil
Commands
.
path
(
"idontexist1234"
)
end
def
test_internal_dev_command_path
assert_equal
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/rbdevcmd.rb"
,
Commands
.
path
(
"rbdevcmd"
)
assert_equal
HOMEBREW_LIBRARY_PATH
/
"dev-cmd/shdevcmd.sh"
,
Commands
.
path
(
"shdevcmd"
)
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