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
4dd6d1af
Commit
4dd6d1af
authored
Jun 24, 2020
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mappings to test_file_finder
- initializers - migrations - schema - factories
parent
4b5250cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
spec/tooling/lib/tooling/test_file_finder_spec.rb
spec/tooling/lib/tooling/test_file_finder_spec.rb
+48
-0
tooling/lib/tooling/test_file_finder.rb
tooling/lib/tooling/test_file_finder.rb
+11
-1
No files found.
spec/tooling/lib/tooling/test_file_finder_spec.rb
View file @
4dd6d1af
...
...
@@ -88,6 +88,54 @@ RSpec.describe Tooling::TestFileFinder do
end
end
context
'when given a factory file'
do
let
(
:file
)
{
'spec/factories/users.rb'
}
it
'returns spec/factories_spec.rb file'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/factories_spec.rb'
)
end
end
context
'when given an ee factory file'
do
let
(
:file
)
{
'ee/spec/factories/users.rb'
}
it
'returns spec/factories_spec.rb file'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/factories_spec.rb'
)
end
end
context
'when given db/structure.sql'
do
let
(
:file
)
{
'db/structure.sql'
}
it
'returns spec/db/schema_spec.rb'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/db/schema_spec.rb'
)
end
end
context
'when given an initializer'
do
let
(
:file
)
{
'config/initializers/action_mailer_hooks.rb'
}
it
'returns the matching initializer spec'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/initializers/action_mailer_hooks_spec.rb'
)
end
end
context
'when given a migration file'
do
let
(
:file
)
{
'db/migrate/20191023152913_add_default_and_free_plans.rb'
}
it
'returns the matching migration spec'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/migrations/add_default_and_free_plans_spec.rb'
)
end
end
context
'when given a post-migration file'
do
let
(
:file
)
{
'db/post_migrate/20200608072931_backfill_imported_snippet_repositories.rb'
}
it
'returns the matching migration spec'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/migrations/backfill_imported_snippet_repositories_spec.rb'
)
end
end
context
'with foss_test_only: true'
do
subject
{
Tooling
::
TestFileFinder
.
new
(
file
,
foss_test_only:
true
)
}
...
...
tooling/lib/tooling/test_file_finder.rb
View file @
4dd6d1af
...
...
@@ -12,7 +12,7 @@ module Tooling
end
def
test_files
impacted_tests
=
ee_impact
|
non_ee_impact
impacted_tests
=
ee_impact
|
non_ee_impact
|
either_impact
impacted_tests
.
impact
(
@file
)
end
...
...
@@ -72,6 +72,16 @@ module Tooling
impact
.
associate
(
%r{^app/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{^(tooling/)?lib/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
lib/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{^spec/(.+)_spec.rb$}
)
{
|
match
|
match
[
0
]
}
impact
.
associate
(
%r{^config/initializers/(.+).rb$}
)
{
|
match
|
"spec/initializers/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{^db/post_migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{^db/migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
end
end
def
either_impact
ImpactedTestFile
.
new
do
|
impact
|
impact
.
associate
(
%r{^(
#{
EE_PREFIX
}
)?spec/factories/.+
\.
rb$}
)
{
'spec/factories_spec.rb'
}
impact
.
associate
(
'db/structure.sql'
)
{
'spec/db/schema_spec.rb'
}
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