-
Notifications
You must be signed in to change notification settings - Fork 34
w: implement idle_time and elapsed time formatting #361
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
Conversation
|
Nah... this project licensed under MIT and the member who want to contributing CAN'T SEE the GPL licensed code:
from our https://github.com/uutils/coreutils/blob/main/CONTRIBUTING.md#writing-code |
|
And very thanks for your contributing, but we need to discuss those code will merge into our code base or not Could you please give us some help? |
|
please don't look at the other implementation. Licenses aren't compatible. |
Sorry about that. I didn't notice that the licenses are incompatible... I'll pay extra attention to that in future contributions. |
|
Looking at test and code are different things. In general, if you need to look at code, look at the BSD implementation. |
Then what is our stance on the tests and the scripts/code that might appear in these tests? E.g. Are we allowed to port and run the tests directly in our project?
Thanks for the explanation. |
The test suite will only check that the inputs, outputs and behaviors are as expected, it only provides the usage of util, not provide the original logic of the util implemented and licensed by GNU and GPL, so it is possible to check the test suite's code And don't forget to fix the CI failures, that's a great job :) |
Thanks for clarifying. I might work toward porting the tests to the rest of the uutils projects (as I'm also interested in contributing to uutils for this year's GSoC), so do let me know if possible license infringements exist.
I suppose that's due to my current implementation is for Linux only which causes the Windows and macOS runners to fail. I don't always have Windows or macOS machines available, so suggestions on ways of porting my code to these two platforms are appreciated ;) |
|
Hum you can see the logs of failed CI, the logs will provided all the things you need to fix CI failure |
|
Use text instead of picture would be better for searching, please use text for pasting logs in future :) |
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.
from CI Style/lint (windows-latest) and Style/lint (macos-latest)
error[E0433]: failed to resolve: use of undeclared crate or module `process`
--> src\uu\w\src\w.rs:241:13
|
241 | process::exit(1);
| ^^^^^^^ use of undeclared crate or module `process`
|
help: consider importing this module
|
6 + use std::process;
|
error: unused variable: `tty`
--> src\uu\w\src\w.rs:99:20
|
99 | fn fetch_idle_time(tty: String) -> Result<Duration, std::io::Error> {
| ^^^ help: if this is intentional, prefix it with an underscore: `_tty`
|
= note: `-D unused-variables` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_variables)]`please fix this error, this error caused build fail :)
|
Cool, to fix the CI failure, the last step: error: function `fetch_idle_time` is never used
--> src/uu/w/src/w.rs:98:4
|
98 | fn fetch_idle_time(_tty: String) -> Result<Duration, std::io::Error> {
| ^^^^^^^^^^^^^^^
|
= note: `-D dead-code` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(dead_code)]`And could you please add unit test for testing the time formatting correctly? |
|
does there any output of ➜ procps git:(main) cargo run -q w
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
➜ procps git:(main) w
15:57:56 up 4:05, 2 users, load average: 1.45, 2.01, 1.88
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
krysztal tty1 - 11:54 4:05m 0.09s 0.09s /usr/bin/startplasma-wayland
krysztal - 11:54 ? 0.00s 9.93s /usr/lib/systemd/systemd --user➜ procps git:(aisuneko/main) cargo run -q w
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
➜ procps git:(aisuneko/main) w
15:59:04 up 4:06, 2 users, load average: 1.43, 1.90, 1.86
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
krysztal tty1 - 11:54 4:06m 0.09s 0.09s /usr/bin/startplasma-wayland
krysztal - 11:54 ? 0.00s 9.97s /usr/lib/systemd/systemd --userhum it seems implemented nothing but header output currently? @sylvestre @cakebaker |
|
@Krysztal112233 It works as intended on my machine, as in #183 (comment) : Are you using the |
|
Weird problem. Our implementation output empty content on Debian. ➜ procps git:(aisuneko/main) cargo run -q w -V
w 0.0.1
➜ procps git:(aisuneko/main) w -V
w from procps-ng 4.0.4But please don't worry, it's not your problem. :) I'll spend some time researching why, this pr looks perfect. Can you add some tests to this file? This test file will ensure that the changes in future don't make regression. https://github.com/uutils/procps/blob/main/tests/by-util/test_w.rs |
|
@Krysztal112233 I get a similar output as @aisuneko on my machine using Arch Linux. |
Krysztal112233
left a comment
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.
Great work, thanks
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #361 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for your PR! |

This is a basic implementation of the display of each users' idle time, as well as a dedicated time formatting function
format_time_elapsedfor this feature, as my first PR to theuutilsproject.The code's logic is largely based on the original source of procpsWe'll, no, as that is considered license violation. I mean just the logic is similar, but the code is rather another implementation.