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
84dfb98e
Commit
84dfb98e
authored
Jan 07, 2022
by
Sanad Liaquat
Committed by
Dan Davison
Jan 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to fetch number of tests a scenario would run
parent
78ff7a35
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
7 deletions
+45
-7
qa/qa/runtime/env.rb
qa/qa/runtime/env.rb
+1
-0
qa/qa/scenario/bootable.rb
qa/qa/scenario/bootable.rb
+7
-0
qa/qa/scenario/shared_attributes.rb
qa/qa/scenario/shared_attributes.rb
+1
-0
qa/qa/scenario/template.rb
qa/qa/scenario/template.rb
+2
-1
qa/qa/specs/runner.rb
qa/qa/specs/runner.rb
+9
-1
qa/spec/scenario/test/integration/github_spec.rb
qa/spec/scenario/test/integration/github_spec.rb
+1
-1
qa/spec/spec_helper.rb
qa/spec/spec_helper.rb
+1
-1
qa/spec/specs/runner_spec.rb
qa/spec/specs/runner_spec.rb
+23
-3
No files found.
qa/qa/runtime/env.rb
View file @
84dfb98e
...
...
@@ -9,6 +9,7 @@ module QA
extend
self
attr_writer
:personal_access_token
,
:admin_personal_access_token
attr_accessor
:dry_run
ENV_VARIABLES
=
Gitlab
::
QA
::
Runtime
::
Env
::
ENV_VARIABLES
...
...
qa/qa/scenario/bootable.rb
View file @
84dfb98e
...
...
@@ -30,6 +30,13 @@ module QA
Runtime
::
Scenario
.
define
(
opt
.
name
,
value
)
end
next
elsif
opt
.
name
==
:count_examples_only
parser
.
on
(
opt
.
arg
,
opt
.
desc
)
do
|
value
|
QA
::
Runtime
::
Env
.
dry_run
=
true
Runtime
::
Scenario
.
define
(
opt
.
name
,
value
)
end
next
end
...
...
qa/qa/scenario/shared_attributes.rb
View file @
84dfb98e
...
...
@@ -13,6 +13,7 @@ module QA
'Specify FEATURE_FLAGS as comma-separated flag=state pairs, e.g., "flag1=enabled,flag2=disabled"'
attribute
:parallel
,
'--parallel'
,
'Execute tests in parallel'
attribute
:loop
,
'--loop'
,
'Execute test repeatedly'
attribute
:count_examples_only
,
'--count-examples-only'
,
'Return the number of examples without running them'
end
end
end
qa/qa/scenario/template.rb
View file @
84dfb98e
...
...
@@ -40,7 +40,8 @@ module QA
##
# Perform before hooks, which are different for CE and EE
#
Runtime
::
Release
.
perform_before_hooks
Runtime
::
Release
.
perform_before_hooks
unless
Runtime
::
Env
.
dry_run
Runtime
::
Feature
.
enable
(
options
[
:enable_feature
])
if
options
.
key?
(
:enable_feature
)
Runtime
::
Feature
.
disable
(
options
[
:disable_feature
])
if
options
.
key?
(
:disable_feature
)
&&
(
@feature_enabled
=
Runtime
::
Feature
.
enabled?
(
options
[
:disable_feature
]))
...
...
qa/qa/specs/runner.rb
View file @
84dfb98e
...
...
@@ -9,6 +9,7 @@ module QA
attr_accessor
:tty
,
:tags
,
:options
DEFAULT_TEST_PATH_ARGS
=
[
'--'
,
File
.
expand_path
(
'./features'
,
__dir__
)].
freeze
DEFAULT_STD_ARGS
=
[
$stderr
,
$stdout
].
freeze
def
initialize
@tty
=
false
...
...
@@ -68,8 +69,15 @@ module QA
ParallelRunner
.
run
(
args
.
flatten
)
elsif
Runtime
::
Scenario
.
attributes
[
:loop
]
LoopRunner
.
run
(
args
.
flatten
)
elsif
Runtime
::
Scenario
.
attributes
[
:count_examples_only
]
args
.
unshift
(
'--dry-run'
)
out
=
StringIO
.
new
RSpec
::
Core
::
Runner
.
run
(
args
.
flatten
,
$stderr
,
out
).
tap
do
|
status
|
abort
if
status
.
nonzero?
end
$stdout
.
puts
out
.
string
.
match
(
/(\d+) examples,/
)[
1
]
else
RSpec
::
Core
::
Runner
.
run
(
args
.
flatten
,
$stderr
,
$stdout
).
tap
do
|
status
|
RSpec
::
Core
::
Runner
.
run
(
args
.
flatten
,
*
DEFAULT_STD_ARGS
).
tap
do
|
status
|
abort
if
status
.
nonzero?
end
end
...
...
qa/spec/scenario/test/integration/github_spec.rb
View file @
84dfb98e
...
...
@@ -2,7 +2,7 @@
RSpec
.
describe
QA
::
Scenario
::
Test
::
Integration
::
Github
do
describe
'#perform'
do
let
(
:env
)
{
spy
(
'Runtime::Env'
,
knapsack?:
false
)
}
let
(
:env
)
{
spy
(
'Runtime::Env'
,
knapsack?:
false
,
dry_run:
false
)
}
before
do
stub_const
(
'QA::Runtime::Env'
,
env
)
...
...
qa/spec/spec_helper.rb
View file @
84dfb98e
...
...
@@ -12,7 +12,7 @@ QaDeprecationToolkitEnv.configure!
Knapsack
::
Adapters
::
RSpecAdapter
.
bind
if
QA
::
Runtime
::
Env
.
knapsack?
QA
::
Runtime
::
Browser
.
configure!
QA
::
Runtime
::
Browser
.
configure!
unless
QA
::
Runtime
::
Env
.
dry_run
QA
::
Runtime
::
AllureReport
.
configure!
QA
::
Runtime
::
Scenario
.
from_env
(
QA
::
Runtime
::
Env
.
runtime_scenario_attributes
)
...
...
qa/spec/specs/runner_spec.rb
View file @
84dfb98e
...
...
@@ -28,6 +28,26 @@ RSpec.describe QA::Specs::Runner do
end
end
context
'when count_examples_only is set as an option'
do
let
(
:out
)
{
StringIO
.
new
}
before
do
QA
::
Runtime
::
Scenario
.
define
(
:count_examples_only
,
true
)
out
.
string
=
'22 examples,'
allow
(
StringIO
).
to
receive
(
:new
).
and_return
(
out
)
end
it
'sets the `--dry-run` flag'
do
expect_rspec_runner_arguments
([
'--dry-run'
,
'--tag'
,
'~orchestrated'
,
'--tag'
,
'~transient'
,
'--tag'
,
'~geo'
,
*
described_class
::
DEFAULT_TEST_PATH_ARGS
],
[
$stderr
,
anything
])
subject
.
perform
end
after
do
QA
::
Runtime
::
Scenario
.
attributes
.
delete
(
:count_examples_only
)
end
end
context
'when tags are set'
do
subject
{
described_class
.
new
.
tap
{
|
runner
|
runner
.
tags
=
%i[orchestrated github]
}
}
...
...
@@ -158,10 +178,10 @@ RSpec.describe QA::Specs::Runner do
end
end
def
expect_rspec_runner_arguments
(
arguments
)
def
expect_rspec_runner_arguments
(
arguments
,
std_arguments
=
described_class
::
DEFAULT_STD_ARGS
)
expect
(
RSpec
::
Core
::
Runner
).
to
receive
(
:run
)
.
with
(
arguments
,
$stderr
,
$stdout
)
.
and_return
(
0
)
.
with
(
arguments
,
*
std_arguments
)
.
and_return
(
0
)
end
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