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
a1cf1f70
Commit
a1cf1f70
authored
Dec 13, 2021
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make FlakyExample#.to_h return a copy of the internal hash
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
3faaf7f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
14 deletions
+20
-14
spec/tooling/rspec_flaky/flaky_example_spec.rb
spec/tooling/rspec_flaky/flaky_example_spec.rb
+10
-8
tooling/rspec_flaky/flaky_example.rb
tooling/rspec_flaky/flaky_example.rb
+8
-4
tooling/rspec_flaky/report.rb
tooling/rspec_flaky/report.rb
+2
-2
No files found.
spec/tooling/rspec_flaky/flaky_example_spec.rb
View file @
a1cf1f70
...
...
@@ -46,14 +46,16 @@ RSpec.describe RspecFlaky::FlakyExample, :aggregate_failures do
let
(
:flaky_example
)
{
described_class
.
new
(
args
)
}
it
'returns valid attributes'
do
expect
(
flaky_example
.
to_h
[
:uid
]).
to
eq
(
flaky_example_attrs
[
:uid
])
expect
(
flaky_example
.
to_h
[
:file
]).
to
eq
(
flaky_example_attrs
[
:file
])
expect
(
flaky_example
.
to_h
[
:line
]).
to
eq
(
flaky_example_attrs
[
:line
])
expect
(
flaky_example
.
to_h
[
:description
]).
to
eq
(
flaky_example_attrs
[
:description
])
expect
(
flaky_example
.
to_h
[
:first_flaky_at
]).
to
eq
(
expected_first_flaky_at
)
expect
(
flaky_example
.
to_h
[
:last_flaky_at
]).
to
eq
(
expected_last_flaky_at
)
expect
(
flaky_example
.
to_h
[
:last_attempts_count
]).
to
eq
(
flaky_example_attrs
[
:last_attempts_count
])
expect
(
flaky_example
.
to_h
[
:flaky_reports
]).
to
eq
(
expected_flaky_reports
)
attrs
=
flaky_example
.
to_h
expect
(
attrs
[
:uid
]).
to
eq
(
flaky_example_attrs
[
:uid
])
expect
(
attrs
[
:file
]).
to
eq
(
flaky_example_attrs
[
:file
])
expect
(
attrs
[
:line
]).
to
eq
(
flaky_example_attrs
[
:line
])
expect
(
attrs
[
:description
]).
to
eq
(
flaky_example_attrs
[
:description
])
expect
(
attrs
[
:first_flaky_at
]).
to
eq
(
expected_first_flaky_at
)
expect
(
attrs
[
:last_flaky_at
]).
to
eq
(
expected_last_flaky_at
)
expect
(
attrs
[
:last_attempts_count
]).
to
eq
(
flaky_example_attrs
[
:last_attempts_count
])
expect
(
attrs
[
:flaky_reports
]).
to
eq
(
expected_flaky_reports
)
end
end
...
...
tooling/rspec_flaky/flaky_example.rb
View file @
a1cf1f70
...
...
@@ -17,11 +17,7 @@ module RspecFlaky
# This represents a flaky RSpec example and is mainly meant to be saved in a JSON file
class
FlakyExample
attr_reader
:attributes
alias_method
:to_h
,
:attributes
def
initialize
(
example_hash
)
example_hash
[
:last_attempts_count
]
||=
example_hash
[
:attempts
]
@attributes
=
{
first_flaky_at:
Time
.
now
,
last_flaky_at:
Time
.
now
,
...
...
@@ -45,5 +41,13 @@ module RspecFlaky
attributes
[
:last_flaky_job
]
=
"
#{
ENV
[
'CI_JOB_URL'
]
}
"
end
end
def
to_h
attributes
.
dup
end
private
attr_reader
:attributes
end
end
tooling/rspec_flaky/report.rb
View file @
a1cf1f70
...
...
@@ -45,13 +45,13 @@ module RspecFlaky
def
prune_outdated
(
days:
OUTDATED_DAYS_THRESHOLD
)
outdated_date_threshold
=
Time
.
now
-
(
3600
*
24
*
days
)
updated_hash
=
flaky_examples
.
dup
recent_flaky_examples
=
flaky_examples
.
dup
.
delete_if
do
|
_uid
,
flaky_example
|
last_flaky_at
=
flaky_example
.
to_h
[
:last_flaky_at
]
last_flaky_at
&&
last_flaky_at
.
to_i
<
outdated_date_threshold
.
to_i
end
self
.
class
.
new
(
RspecFlaky
::
FlakyExamplesCollection
.
new
(
updated_hash
))
self
.
class
.
new
(
RspecFlaky
::
FlakyExamplesCollection
.
new
(
recent_flaky_examples
))
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