BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
lexer.rb
lib/gitlab/ci/pipeline/expression/lexer.rb
+1
-1
statement.rb
lib/gitlab/ci/pipeline/expression/statement.rb
+3
-3
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