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
b92ce0cc
Commit
b92ce0cc
authored
Feb 22, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename pipeline expressions statement exception class
parent
d532a9cb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
lib/gitlab/ci/pipeline/expression/lexer.rb
lib/gitlab/ci/pipeline/expression/lexer.rb
+1
-1
lib/gitlab/ci/pipeline/expression/statement.rb
lib/gitlab/ci/pipeline/expression/statement.rb
+3
-3
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
+12
-1
No files found.
lib/gitlab/ci/pipeline/expression/lexer.rb
View file @
b92ce0cc
...
...
@@ -20,7 +20,7 @@ module Gitlab
def
tokenize
MAX_CYCLES
.
times
do
LEXEMES
.
each
do
|
lexeme
|
@scanner
.
s
can
(
/\s+/
)
# ignore whitespace
@scanner
.
s
kip
(
/\s+/
)
# ignore whitespace
lexeme
.
scan
(
@scanner
).
tap
do
|
token
|
@tokens
.
push
(
token
)
if
token
.
present?
...
...
lib/gitlab/ci/pipeline/expression/statement.rb
View file @
b92ce0cc
...
...
@@ -3,7 +3,7 @@ module Gitlab
module
Pipeline
module
Expression
class
Statement
Parser
Error
=
Class
.
new
(
StandardError
)
Statement
Error
=
Class
.
new
(
StandardError
)
GRAMMAR
=
[
%w[variable equals string]
,
...
...
@@ -37,10 +37,10 @@ module Gitlab
# a reverse descent parse tree "by hand".
#
def
parse_tree
raise
Parser
Error
if
lexemes
.
empty?
raise
Statement
Error
if
lexemes
.
empty?
unless
GRAMMAR
.
find
{
|
syntax
|
syntax
==
lexemes
}
raise
Parser
Error
,
'Unknown pipeline expression!'
raise
Statement
Error
,
'Unknown pipeline expression!'
end
if
tokens
.
many?
...
...
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
View file @
b92ce0cc
...
...
@@ -25,10 +25,21 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end
describe
'#parse_tree'
do
context
'when expression is empty'
do
let
(
:text
)
{
''
}
it
'raises an error'
do
expect
{
subject
.
parse_tree
}
.
to
raise_error
described_class
::
StatementError
end
end
context
'when expression grammar is incorrect'
do
let
(
:text
)
{
'$VAR "text"'
}
it
'raises an error'
do
expect
{
subject
.
parse_tree
}
.
to
raise_error
described_class
::
Parser
Error
.
to
raise_error
described_class
::
Statement
Error
end
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