Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a2618310
Commit
a2618310
authored
Jan 24, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Process::Status rather than an integer
However keep backward compatibility
parent
0bf918f0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
20 deletions
+20
-20
lib/gitlab/popen.rb
lib/gitlab/popen.rb
+3
-3
lib/gitlab/popen/runner.rb
lib/gitlab/popen/runner.rb
+6
-6
scripts/static-analysis
scripts/static-analysis
+2
-2
spec/lib/gitlab/popen/runner_spec.rb
spec/lib/gitlab/popen/runner_spec.rb
+8
-8
spec/lib/gitlab/popen_spec.rb
spec/lib/gitlab/popen_spec.rb
+1
-1
No files found.
lib/gitlab/popen.rb
View file @
a2618310
...
...
@@ -11,7 +11,7 @@ module Gitlab
def
popen
(
cmd
,
path
=
nil
,
vars
=
{},
&
block
)
result
=
popen_with_detail
(
cmd
,
path
,
vars
,
&
block
)
[
result
.
stdout
<<
result
.
stderr
,
result
.
status
]
[
result
.
stdout
<<
result
.
stderr
,
result
.
status
&
.
exitstatus
]
end
# Returns Result
...
...
@@ -30,7 +30,7 @@ module Gitlab
cmd_stdout
=
''
cmd_stderr
=
''
cmd_status
=
0
cmd_status
=
nil
start
=
Time
.
now
Open3
.
popen3
(
vars
,
*
cmd
,
options
)
do
|
stdin
,
stdout
,
stderr
,
wait_thr
|
...
...
@@ -39,7 +39,7 @@ module Gitlab
cmd_stdout
=
stdout
.
read
cmd_stderr
=
stderr
.
read
cmd_status
=
wait_thr
.
value
.
exitstatus
cmd_status
=
wait_thr
.
value
end
Result
.
new
(
cmd
,
cmd_stdout
,
cmd_stderr
,
cmd_status
,
Time
.
now
-
start
)
...
...
lib/gitlab/popen/runner.rb
View file @
a2618310
...
...
@@ -20,12 +20,12 @@ module Gitlab
end
end
def
all_
good
?
all_s
tatus_zero
?
&&
all_stderr_empty?
def
all_
success_and_clean
?
all_s
uccess
?
&&
all_stderr_empty?
end
def
all_s
tatus_zero
?
results
.
all?
{
|
result
|
result
.
status
.
zero
?
}
def
all_s
uccess
?
results
.
all?
{
|
result
|
result
.
status
.
success
?
}
end
def
all_stderr_empty?
...
...
@@ -33,12 +33,12 @@ module Gitlab
end
def
failed_results
results
.
select
{
|
result
|
result
.
status
.
nonzero
?
}
results
.
reject
{
|
result
|
result
.
status
.
success
?
}
end
def
warned_results
results
.
select
do
|
result
|
result
.
status
.
zero
?
&&
!
result
.
stderr
.
empty?
result
.
status
.
success
?
&&
!
result
.
stderr
.
empty?
end
end
end
...
...
scripts/static-analysis
View file @
a2618310
...
...
@@ -57,9 +57,9 @@ puts '==================================================='
puts
puts
if
static_analysis
.
all_
good
?
if
static_analysis
.
all_
success_and_clean
?
puts
'All static analyses passed successfully.'
elsif
static_analysis
.
all_s
tatus_zero
?
elsif
static_analysis
.
all_s
uccess
?
puts
'All static analyses passed successfully, but we have warnings:'
puts
...
...
spec/lib/gitlab/popen/runner_spec.rb
View file @
a2618310
...
...
@@ -11,43 +11,43 @@ describe Gitlab::Popen::Runner do
end
end
describe
'#all_
good
?'
do
describe
'#all_
success_and_clean
?'
do
it
'returns true when exit status is 0 and stderr is empty'
do
run_command
expect
(
subject
).
to
be_all_
good
expect
(
subject
).
to
be_all_
success_and_clean
end
it
'returns false when exit status is not 0'
do
run_command
(
exitstatus:
1
)
expect
(
subject
).
not_to
be_all_
good
expect
(
subject
).
not_to
be_all_
success_and_clean
end
it
'returns false when exit stderr has something'
do
run_command
(
stderr:
'stderr'
)
expect
(
subject
).
not_to
be_all_
good
expect
(
subject
).
not_to
be_all_
success_and_clean
end
end
describe
'#all_s
tatus_zero
?'
do
describe
'#all_s
uccess
?'
do
it
'returns true when exit status is 0'
do
run_command
expect
(
subject
).
to
be_all_s
tatus_zero
expect
(
subject
).
to
be_all_s
uccess
end
it
'returns false when exit status is not 0'
do
run_command
(
exitstatus:
1
)
expect
(
subject
).
not_to
be_all_s
tatus_zero
expect
(
subject
).
not_to
be_all_s
uccess
end
it
'returns true'
do
run_command
(
stderr:
'stderr'
)
expect
(
subject
).
to
be_all_s
tatus_zero
expect
(
subject
).
to
be_all_s
uccess
end
end
...
...
spec/lib/gitlab/popen_spec.rb
View file @
a2618310
...
...
@@ -16,7 +16,7 @@ describe Gitlab::Popen do
it
{
expect
(
subject
.
cmd
).
to
eq
(
cmd
)
}
it
{
expect
(
subject
.
stdout
).
to
eq
(
"1
\n
"
)
}
it
{
expect
(
subject
.
stderr
).
to
eq
(
"2
\n
"
)
}
it
{
expect
(
subject
.
status
).
to
eq
(
3
)
}
it
{
expect
(
subject
.
status
.
exitstatus
).
to
eq
(
3
)
}
it
{
expect
(
subject
.
duration
).
to
be_kind_of
(
Numeric
)
}
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment