procfetch icon indicating copy to clipboard operation
procfetch copied to clipboard

Get user name by getpwuid instead of environment variable USER

Open youpong opened this issue 1 year ago • 7 comments

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

  • #148

youpong avatar May 14 '24 08:05 youpong

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 avatar May 14 '24 08:05 youpong

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

youpong avatar May 14 '24 12:05 youpong

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?

youpong avatar May 14 '24 12:05 youpong

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

TanmayPatil105 avatar May 14 '24 13:05 TanmayPatil105

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.

youpong avatar May 14 '24 15:05 youpong

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

TanmayPatil105 avatar May 14 '24 17:05 TanmayPatil105

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

youpong avatar May 15 '24 05:05 youpong

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

TanmayPatil105 avatar May 21 '24 17:05 TanmayPatil105

~~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.

youpong avatar May 22 '24 00:05 youpong