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
dffd5562
Commit
dffd5562
authored
8 years ago
by
Mike McQuaid
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #704 from eirinikos/add-cmd-audit-unit-tests
tests: add cmd/audit unit tests
parents
87173cb7
5a965d30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/test/test_cmd_audit.rb
+94
-0
94 additions, 0 deletions
Library/Homebrew/test/test_cmd_audit.rb
with
94 additions
and
0 deletions
Library/Homebrew/test/test_cmd_audit.rb
+
94
−
0
View file @
dffd5562
...
...
@@ -373,4 +373,98 @@ class FormulaAuditorTests < Homebrew::TestCase
ensure
ENV
[
"HOMEBREW_NO_GITHUB_API"
]
=
original_value
end
def
test_audit_caveats
fa
=
formula_auditor
"foo"
,
<<-
EOS
.
undent
class Foo < Formula
homepage "http://example.com/foo"
url "http://example.com/foo-1.0.tgz"
def caveats
"setuid"
end
end
EOS
fa
.
audit_caveats
assert_equal
[
"Don't recommend setuid in the caveats, suggest sudo instead."
],
fa
.
problems
end
def
test_audit_desc
formula_descriptions
=
[
{
:name
=>
"foo"
,
:desc
=>
nil
,
:problem
=>
"Formula should have a desc"
},
{
:name
=>
"bar"
,
:desc
=>
"bar"
*
30
,
:problem
=>
"Description is too long"
},
{
:name
=>
"baz"
,
:desc
=>
"Baz commandline tool"
,
:problem
=>
"Description should use
\"
command-line
\"
"
},
{
:name
=>
"qux"
,
:desc
=>
"A tool called Qux"
,
:problem
=>
"Description shouldn't start with an indefinite article"
},
]
formula_descriptions
.
each
do
|
formula
|
content
=
<<-
EOS
.
undent
class
#{
Formulary
.
class_s
(
formula
[
:name
])
}
< Formula
url "http://example.com/
#{
formula
[
:name
]
}
-1.0.tgz"
desc "
#{
formula
[
:desc
]
}
"
end
EOS
fa
=
formula_auditor
formula
[
:name
],
content
,
:strict
=>
true
fa
.
audit_desc
assert_match
formula
[
:problem
],
fa
.
problems
.
first
end
end
def
test_audit_homepage
fa
=
formula_auditor
"foo"
,
<<-
EOS
.
undent
,
:online
=>
true
class Foo < Formula
homepage "ftp://example.com/foo"
url "http://example.com/foo-1.0.tgz"
end
EOS
fa
.
audit_homepage
assert_equal
[
"The homepage should start with http or https "
\
"(URL is
#{
fa
.
formula
.
homepage
}
)."
,
"The homepage is not reachable "
\
"(curl exit code
#{
$?
.
exitstatus
}
)"
],
fa
.
problems
formula_homepages
=
{
"bar"
=>
"http://www.freedesktop.org/wiki/bar"
,
"baz"
=>
"http://www.freedesktop.org/wiki/Software/baz"
,
"qux"
=>
"https://code.google.com/p/qux"
,
"quux"
=>
"http://github.com/quux"
,
"corge"
=>
"http://savannah.nongnu.org/corge"
,
"grault"
=>
"http://grault.github.io/"
,
"garply"
=>
"http://www.gnome.org/garply"
,
"waldo"
=>
"http://www.gnu.org/waldo"
,
}
formula_homepages
.
each
do
|
name
,
homepage
|
fa
=
formula_auditor
name
,
<<-
EOS
.
undent
class
#{
Formulary
.
class_s
(
name
)
}
< Formula
homepage "
#{
homepage
}
"
url "http://example.com/
#{
name
}
-1.0.tgz"
end
EOS
fa
.
audit_homepage
if
homepage
=~
%r{http:
\/\/
www
\.
freedesktop
\.
org}
if
homepage
=~
/Software/
assert_match
"
#{
homepage
}
should be styled "
\
"`https://wiki.freedesktop.org/www/Software/project_name`"
,
fa
.
problems
.
first
else
assert_match
"
#{
homepage
}
should be styled "
\
"`https://wiki.freedesktop.org/project_name`"
,
fa
.
problems
.
first
end
elsif
homepage
=~
%r{https:
\/\/
code
\.
google
\.
com}
assert_match
"
#{
homepage
}
should end with a slash"
,
fa
.
problems
.
first
else
assert_match
"Please use https:// for
#{
homepage
}
"
,
fa
.
problems
.
first
end
end
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