TanmayPatil105 / procfetch

🎨 Yet another command-line system information utility written in C++
https://tanmaypatil105.github.io/procfetch/
GNU General Public License v3.0
23 stars 11 forks source link

Get user name by getpwuid instead of environment variable USER #150

Closed youpong closed 6 months ago

youpong commented 6 months ago

Description

getlogin(2) does not return the expected value. Instead, getpwuid(3) can be used to retrieve the user name.

To test this, I've prepared a repository youpong/getuser. See function test_getlogin() for getlogin(2) behavior, function getuser() for an example implementation in getpwuid(3). You can see the results of the multi-platform behavior in the GitHub Actions log.

Related Issue

youpong commented 6 months ago

Unit tests are failing. The reason is that ubuntu:latest in Github Actions is still using 22.04 LTS, so the std::format adopted in standard C++20 is not available.

youpong commented 6 months ago

clang++ (not g++) on Ubuntu 22.04 LTS can use std::format. I would like to propose to use clang++ for unit test.

youpong commented 6 months ago

Coverage testing has failed. This is because it uses g++.

Maybe Ubuntu 24.04 LTS will be available in a few months, so it's a not bad idea not to take action. What do you think?

TanmayPatil105 commented 6 months ago

I believe we would want procfetch to be compatible with older distributions too, including the tests!

youpong commented 6 months ago

I think that being available in various distributions, old and new, is not about being able to build, but about having binaries available. And while unit testing should be checked with every commit, coverage testing should be enough to get a trend every few months.

TanmayPatil105 commented 6 months ago

1 hour ago: https://github.blog/changelog/2024-05-14-github-hosted-runners-public-beta-of-ubuntu-24-04-is-now-available/

youpong commented 6 months ago

Thank you for information. I'm traveling for a couple of days. I'll take a look later.

TanmayPatil105 commented 6 months ago

We'll also need to update the unit test images to 24.04.

youpong commented 6 months ago

~~Added ubuntu-24.04 as a runner host for unit testing. ubuntu-latest is left as it is. It is OK if the test succeeds on ubuntu-24.04, even if it fails on ubuntu-latest.~~

Update ubuntu-latset to ubuntu-24.04 on unit testing.

The OS version of ubuntu-latest is 22.04 now, but will be 24.04 in a few months. We will remove update ubuntu-24.04 to ubuntu-latest on unit testing and coverage testing at that time.