-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add last Utility #65
base: main
Are you sure you want to change the base?
Add last Utility #65
Conversation
src/uu/last/Cargo.toml
Outdated
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
src/uu/last/src/platform/unix.rs
Outdated
|
||
// "%b %e %H:%M" | ||
let time_format: Vec<time::format_description::FormatItem> = | ||
time::format_description::parse(description).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not handling the error ? unwrap seems risky, no ? :)
src/uu/last/src/platform/unix.rs
Outdated
// "%b %e %H:%M" | ||
let time_format: Vec<time::format_description::FormatItem> = | ||
time::format_description::parse(description).unwrap(); | ||
ut.login_time().format(&time_format).unwrap() // LC_ALL=C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/uu/last/src/platform/unix.rs
Outdated
if counter >= self.limit && self.limit > 0 { | ||
break; | ||
} | ||
// println!("|{}| |{}| |{}|", ut.user(), time_string(&ut), ut.tty_device()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the comments
i guess you saw it but the builds are failing |
Windows and macOS is still broken. I'll work on fixing those. I will also fix the still existing linting issues. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65 +/- ##
==========================================
- Coverage 69.35% 60.05% -9.30%
==========================================
Files 14 18 +4
Lines 1142 1467 +325
Branches 164 233 +69
==========================================
+ Hits 792 881 +89
- Misses 336 460 +124
- Partials 14 126 +112
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
It looks like I have everything working now. The existing errors appear to be from other utilities.
|
The GitHub runner images do not contain "still logged in" as no user logs into the system. Processes are only running, so only "still running" is present.
GitHub's Linux images only have "still running". The MacOS images have "still logged in". The regex check was changed to account for both options.
dunno if it is hard to do but could you please add tests with an invalid /var/log/wtmp to check that the error management is properly done ? thanks |
Added one test so far that matches the behavior with the linux org implementation. That seems like the only test I could get working so far. There were some discrepancies I noticed that I think are beyond my implementation, and involve the For example, if you have a file of arbitrary bytes (Say a file of one long string of all 'a' characters) which can fit into |
a bunch of jobs are failing, could you please have a look? Like:
|
I implemented the last utility in #18.
Limitations
Tests
I added some tests too to go along with the PR. They are kind of simplistic though in that they only do a check to verify there was some output. The timestamp checks only do a simplistic regex check on the output.