Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling of Step controller #1862

Merged
merged 2 commits into from Nov 21, 2018

Conversation

Martchus
Copy link
Contributor

my $file = path($job->result_dir(), $module_detail->{text})->open('<:encoding(UTF-8)');
my @file_content;
if (defined $file) {
@file_content = <$file>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be possible to replace this whole block with a slurp.

use Mojo::Util 'decode';
...
my $file_content = decode 'UTF-8', path($job->result_dir(), $module_detail->{text})->slurp;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that Mojo::File::open already throws an exception if opening the file failed, so the defined $file check shouldn't be doing anything there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That block was already there. It just has been re-intended to keep the code simpler. But I can clean it up in a further commit of course.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You re-indent it you own it (in git blame). 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually have a lot of places where we could use slurp and spurt too... but this ain the place to address that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@codecov
Copy link

codecov bot commented Nov 15, 2018

Codecov Report

Merging #1862 into master will increase coverage by 18.3%.
The diff coverage is 96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1862      +/-   ##
==========================================
+ Coverage   71.73%   90.04%   +18.3%     
==========================================
  Files         127      148      +21     
  Lines        9433    10348     +915     
==========================================
+ Hits         6767     9318    +2551     
+ Misses       2666     1030    -1636
Impacted Files Coverage Δ
lib/OpenQA/WebAPI/Controller/Step.pm 84.59% <96%> (+0.36%) ⬆️
lib/OpenQA/Worker/Jobs.pm 73.61% <0%> (-4.1%) ⬇️
lib/OpenQA.pm 71.79% <0%> (ø)
lib/OpenQA/WebAPI/Controller/API/V1/Command.pm 30.76% <0%> (ø)
lib/OpenQA/Script.pm 90% <0%> (ø)
lib/OpenQA/Parser/Format/Base.pm 100% <0%> (ø)
lib/OpenQA/WebAPI/Plugin/Fedmsg.pm 96.87% <0%> (ø)
lib/OpenQA/Worker/Cache/Task.pm 100% <0%> (ø)
lib/OpenQA/WebAPI/Controller/API/V1/Locks.pm 96.77% <0%> (ø)
lib/OpenQA/WebAPI/Controller/Admin/Influxdb.pm 98.03% <0%> (ø)
... and 75 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f04d73...d7ebc2e. Read the comment docs.

@Martchus
Copy link
Contributor Author

Seems like using slurp breaks one of the tests because now a newline is missing.

@Martchus
Copy link
Contributor Author

In fact the previous code wrongly inserted a white-space and also the test wrongly expected that to be there. So using slurp actually fixes a bug and I now adapted the test.

@Martchus Martchus merged commit dee7a2c into os-autoinst:master Nov 21, 2018
@Martchus Martchus deleted the step_error_handling branch November 21, 2018 13:48
coolo pushed a commit that referenced this pull request Nov 21, 2018
commit dee7a2c
Merge: ee43dab d7ebc2e
Author:     Martchus <martchus@gmx.net>
AuthorDate: Wed Nov 21 14:48:09 2018 +0100
Commit:     GitHub <noreply@github.com>
CommitDate: Wed Nov 21 14:48:09 2018 +0100

    Merge pull request #1862 from Martchus/step_error_handling

    Improve error handling of Step controller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants