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
8c71cbde
Commit
8c71cbde
authored
Jun 01, 2020
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move TestFileFinder into tooling
parent
cdaa892d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
125 additions
and
105 deletions
+125
-105
.gitlab/ci/rails.gitlab-ci.yml
.gitlab/ci/rails.gitlab-ci.yml
+1
-1
.gitlab/ci/rules.gitlab-ci.yml
.gitlab/ci/rules.gitlab-ci.yml
+1
-1
spec/fast_spec_helper.rb
spec/fast_spec_helper.rb
+2
-0
spec/lib/quality/test_file_finder_spec.rb
spec/lib/quality/test_file_finder_spec.rb
+0
-99
spec/tooling/lib/tooling/test_file_finder_spec.rb
spec/tooling/lib/tooling/test_file_finder_spec.rb
+111
-0
tooling/bin/find_foss_tests
tooling/bin/find_foss_tests
+4
-3
tooling/lib/tooling/test_file_finder.rb
tooling/lib/tooling/test_file_finder.rb
+6
-1
No files found.
.gitlab/ci/rails.gitlab-ci.yml
View file @
8c71cbde
...
...
@@ -339,7 +339,7 @@ rspec foss-impact:
-
run_timed_command "scripts/gitaly-test-build"
-
run_timed_command "scripts/gitaly-test-spawn"
-
source scripts/rspec_helpers.sh
-
scripts
/find_foss_tests tmp/matching_foss_tests.txt
-
tooling/bin
/find_foss_tests tmp/matching_foss_tests.txt
-
rspec_simple_job "--tag ~quarantine --tag ~geo --tag ~level:migration $(cat tmp/matching_foss_tests.txt)"
artifacts
:
expire_in
:
7d
...
...
.gitlab/ci/rules.gitlab-ci.yml
View file @
8c71cbde
spec/fast_spec_helper.rb
View file @
8c71cbde
...
...
@@ -13,4 +13,6 @@ require 'active_support/all'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'ee/lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'tooling/lib'
ActiveSupport
::
XmlMini
.
backend
=
'Nokogiri'
spec/lib/quality/test_file_finder_spec.rb
deleted
100644 → 0
View file @
cdaa892d
# frozen_string_literal: true
require
'fast_spec_helper'
describe
Quality
::
TestFileFinder
do
let
(
:file
)
{
'app/finders/admin/projects_finder.rb'
}
let
(
:test_files
)
{
[
'spec/finders/admin/projects_finder_spec.rb'
]
}
subject
{
Quality
::
TestFileFinder
.
new
(
file
)
}
shared_examples
'finding matching test files'
do
it
'returns matching test files'
do
expect
(
subject
.
test_files
).
to
match_array
(
test_files
)
end
end
shared_examples
'not finding a matching test file'
do
it
'returns empty array'
do
expect
(
subject
.
test_files
).
to
be_empty
end
end
describe
'#test_files'
do
it_behaves_like
'finding matching test files'
context
'when given non .rb files'
do
let
(
:file
)
{
'app/assets/images/emoji.png'
}
it_behaves_like
'not finding a matching test file'
end
context
'when given file in app/'
do
let
(
:file
)
{
'app/finders/admin/projects_finder.rb'
}
let
(
:test_files
)
{
[
'spec/finders/admin/projects_finder_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'when given file in lib/'
do
let
(
:file
)
{
'lib/banzai/color_parser.rb'
}
let
(
:test_files
)
{
[
'spec/lib/banzai/color_parser_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'when given a test file'
do
let
(
:file
)
{
'spec/lib/banzai/color_parser_spec.rb'
}
let
(
:test_files
)
{
[
'spec/lib/banzai/color_parser_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'when given an ee app file'
do
let
(
:file
)
{
'ee/app/models/analytics/cycle_analytics/group_level.rb'
}
let
(
:test_files
)
{
[
'ee/spec/models/analytics/cycle_analytics/group_level_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'when given an ee module file'
do
let
(
:file
)
{
'ee/app/models/ee/user.rb'
}
let
(
:test_files
)
{
[
'spec/app/models/user_spec.rb'
,
'ee/spec/models/ee/user_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'when given an ee lib file'
do
let
(
:file
)
{
'ee/lib/flipper_session.rb'
}
let
(
:test_files
)
{
[
'ee/spec/lib/flipper_session_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'when given an ee test file'
do
let
(
:file
)
{
'ee/spec/models/container_registry/event_spec.rb'
}
let
(
:test_files
)
{
[
'ee/spec/models/container_registry/event_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'when given an ee module test file'
do
let
(
:file
)
{
'ee/spec/models/ee/appearance_spec.rb'
}
let
(
:test_files
)
{
[
'ee/spec/models/ee/appearance_spec.rb'
,
'spec/models/appearance_spec.rb'
]
}
it_behaves_like
'finding matching test files'
end
context
'with foss_test_only: true'
do
let
(
:file
)
{
'ee/app/models/ee/user.rb'
}
let
(
:test_files
)
{
[
'spec/app/models/user_spec.rb'
]
}
subject
{
Quality
::
TestFileFinder
.
new
(
file
,
foss_test_only:
true
)
}
it
'excludes matching ee test files'
do
expect
(
subject
.
test_files
).
to
match_array
(
test_files
)
end
end
end
end
spec/tooling/lib/tooling/test_file_finder_spec.rb
0 → 100644
View file @
8c71cbde
# frozen_string_literal: true
require
'fast_spec_helper'
describe
Tooling
::
TestFileFinder
do
subject
{
Tooling
::
TestFileFinder
.
new
(
file
)
}
describe
'#test_files'
do
context
'when given non .rb files'
do
let
(
:file
)
{
'app/assets/images/emoji.png'
}
it
'does not return a test file'
do
expect
(
subject
.
test_files
).
to
be_empty
end
end
context
'when given file in app/'
do
let
(
:file
)
{
'app/finders/admin/projects_finder.rb'
}
it
'returns the matching app spec file'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/finders/admin/projects_finder_spec.rb'
)
end
end
context
'when given file in lib/'
do
let
(
:file
)
{
'lib/banzai/color_parser.rb'
}
it
'returns the matching app spec file'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/lib/banzai/color_parser_spec.rb'
)
end
end
context
'when given a file in tooling/'
do
let
(
:file
)
{
'tooling/lib/quality/test_file_finder.rb'
}
it
'returns the matching tooling test'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/tooling/lib/quality/test_file_finder_spec.rb'
)
end
end
context
'when given a test file'
do
let
(
:file
)
{
'spec/lib/banzai/color_parser_spec.rb'
}
it
'returns the matching test file itself'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/lib/banzai/color_parser_spec.rb'
)
end
end
context
'when given an app file in ee/'
do
let
(
:file
)
{
'ee/app/models/analytics/cycle_analytics/group_level.rb'
}
it
'returns the matching ee/ test file'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'ee/spec/models/analytics/cycle_analytics/group_level_spec.rb'
)
end
end
context
'when given a module file in ee/'
do
let
(
:file
)
{
'ee/app/models/ee/user.rb'
}
it
'returns the matching ee/ module test file and the ee/ model test file'
do
test_files
=
[
'ee/spec/models/ee/user_spec.rb'
,
'spec/app/models/user_spec.rb'
]
expect
(
subject
.
test_files
).
to
contain_exactly
(
*
test_files
)
end
end
context
'when given a lib file in ee/'
do
let
(
:file
)
{
'ee/lib/flipper_session.rb'
}
it
'returns the matching ee/ lib test file'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'ee/spec/lib/flipper_session_spec.rb'
)
end
end
context
'when given a test file in ee/'
do
let
(
:file
)
{
'ee/spec/models/container_registry/event_spec.rb'
}
it
'returns the test file itself'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'ee/spec/models/container_registry/event_spec.rb'
)
end
end
context
'when given a module test file in ee/'
do
let
(
:file
)
{
'ee/spec/models/ee/appearance_spec.rb'
}
it
'returns the matching module test file itself and the corresponding spec model test file'
do
test_files
=
[
'ee/spec/models/ee/appearance_spec.rb'
,
'spec/models/appearance_spec.rb'
]
expect
(
subject
.
test_files
).
to
contain_exactly
(
*
test_files
)
end
end
context
'with foss_test_only: true'
do
subject
{
Tooling
::
TestFileFinder
.
new
(
file
,
foss_test_only:
true
)
}
context
'when given a module file in ee/'
do
let
(
:file
)
{
'ee/app/models/ee/user.rb'
}
it
'returns only the corresponding spec model test file in foss'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/app/models/user_spec.rb'
)
end
end
context
'when given an app file in ee/'
do
let
(
:file
)
{
'ee/app/models/approval.rb'
}
it
'returns no test file in foss'
do
expect
(
subject
.
test_files
).
to
be_empty
end
end
end
end
end
scripts
/find_foss_tests
→
tooling/bin
/find_foss_tests
View file @
8c71cbde
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative
'../lib/gitlab/popen'
require_relative
'../lib/
quality
/test_file_finder'
require_relative
'../
../
lib/gitlab/popen'
require_relative
'../lib/
tooling
/test_file_finder'
output_file
=
ARGV
.
shift
...
...
@@ -19,7 +20,7 @@ end
changed_files
=
git_diff
.
stdout
.
split
(
"
\n
"
)
tests_to_run
=
changed_files
.
flat_map
do
|
file
|
test_files
=
Quality
::
TestFileFinder
.
new
(
file
,
foss_test_only:
true
).
test_files
test_files
=
Tooling
::
TestFileFinder
.
new
(
file
,
foss_test_only:
true
).
test_files
test_files
.
select
{
|
f
|
File
.
exist?
(
f
)
}
end
...
...
lib/quality
/test_file_finder.rb
→
tooling/lib/tooling
/test_file_finder.rb
View file @
8c71cbde
...
...
@@ -3,7 +3,7 @@
require
'ostruct'
require
'set'
module
Quality
module
Tooling
class
TestFileFinder
RUBY_EXTENSION
=
'.rb'
EE_PREFIX
=
'ee/'
...
...
@@ -43,6 +43,7 @@ module Quality
OpenStruct
.
new
.
tap
do
|
foss
|
foss
.
app
=
%r{^app/(.+)
\.
rb$}
foss
.
lib
=
%r{^lib/(.+)
\.
rb$}
foss
.
tooling
=
%r{^(tooling/lib/.+)
\.
rb$}
foss
.
spec
=
%r{^spec/(.+)_spec.rb$}
foss
.
spec_dir
=
'spec'
end
...
...
@@ -57,6 +58,10 @@ module Quality
result
<<
"
#{
context
.
spec_dir
}
/lib/
#{
match
[
1
]
}
_spec.rb"
end
if
(
match
=
context
.
tooling
&
.
match
(
file
))
result
<<
"
#{
context
.
spec_dir
}
/
#{
match
[
1
]
}
_spec.rb"
end
if
context
.
spec
&
.
match
(
file
)
result
<<
file
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