Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chromebrew
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
0
Merge Requests
0
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
chromebrew
Commits
6866d992
Commit
6866d992
authored
Jan 14, 2019
by
James Larrowe
Committed by
Ed Reel
Jan 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests. (#3081)
Improve logic
parent
0419a38b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
tests/no_cycles.rb
tests/no_cycles.rb
+11
-3
No files found.
tests/no_cycles.rb
View file @
6866d992
...
@@ -20,17 +20,18 @@ end
...
@@ -20,17 +20,18 @@ end
# @state will store :on_path for vertices on the current dependency path
# @state will store :on_path for vertices on the current dependency path
# and :visited for vertices that have already been checked not to lead to
# and :visited for vertices that have already been checked not to lead to
# cycles.
# cycles.
@failed
=
0
@state
=
{}
@state
=
{}
@path
=
[]
@path
=
[]
def
dfs
(
pkg
)
def
dfs
(
pkg
)
@path
.
push
(
pkg
.
name
)
@path
.
push
(
pkg
.
name
)
if
@state
[
pkg
]
==
:on_path
if
@state
[
pkg
]
==
:on_path
puts
"Found dependency cycle!"
.
lightred
puts
"
\n
Found dependency cycle!"
.
lightred
while
@path
.
first
!=
@path
.
last
while
@path
.
first
!=
@path
.
last
@path
.
shift
@path
.
shift
end
end
puts
@path
.
to_s
puts
@path
.
to_s
exit
1
@failed
+=
1
elsif
@state
[
pkg
]
==
nil
elsif
@state
[
pkg
]
==
nil
@state
[
pkg
]
=
:on_path
@state
[
pkg
]
=
:on_path
if
pkg
.
dependencies
if
pkg
.
dependencies
...
@@ -50,4 +51,11 @@ end
...
@@ -50,4 +51,11 @@ end
dfs
(
pkg
)
dfs
(
pkg
)
end
end
puts
"No dependency cycles found."
.
lightgreen
@cycles
=
"cycles"
@cycles
=
"cycle"
if
@failed
==
1
if
@failed
>
0
abort
"
\n
#{
@failed
}
dependency
#{
@cycles
}
found."
.
lightred
else
puts
"
\n
No dependency cycles found."
.
lightgreen
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