Skip to content

Ticket #4981: do not show color warning with --nocolor#5081

Merged
zyv merged 1 commit intoMidnightCommander:masterfrom
peripherium:fix/color-error-while-nocolor
Apr 5, 2026
Merged

Ticket #4981: do not show color warning with --nocolor#5081
zyv merged 1 commit intoMidnightCommander:masterfrom
peripherium:fix/color-error-while-nocolor

Conversation

@peripherium
Copy link
Copy Markdown
Contributor

@peripherium peripherium commented Mar 27, 2026

Proposed changes

Suppress the color capability warning when --nocolor is used.

The warning is still shown if a skin is explicitly requested via menu.

Additionally, the global variable mc_skin_is_init was removed:
it is set with seemingly meaningful values but never actually used.

Checklist

  • I have referenced the issue(s) resolved by this PR (if any)
  • I have signed-off my contribution with git commit --amend -s
  • Lint and unit tests pass locally with my changes (make indent && make check)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

Quick question: in earlier commits I was asked to add a test function
even when the function already existed. Should a test function be
added for every existing function in the future? If so, I can add
one for this change as well.

@github-actions github-actions bot added this to the Future Releases milestone Mar 27, 2026
@github-actions github-actions bot added needs triage Needs triage by maintainers prio: medium Has the potential to affect progress labels Mar 27, 2026
@zyv zyv added area: skin Theming support and skin files and removed needs triage Needs triage by maintainers labels Mar 27, 2026
@zyv zyv modified the milestones: Future Releases, 4.9.0 Mar 27, 2026
@zyv
Copy link
Copy Markdown
Member

zyv commented Mar 27, 2026

Quick question: in earlier commits I was asked to add a test function even when the function already existed. Should a test function be added for every existing function in the future? If so, I can add one for this change as well.

In general, I tend to ask for a test when 1) the changes seem "risky" according to my subjective feeling and 2) it seems to me that they can indeed be tested relatively simply with the current setup.

I mostly have a feeling that changes are "risky" when an old large function full of loops and conditionals, and possibly external variables, which is otherwise not covered with tests, is changed, and likely in a non-trivial fashion.

In this case, I wouldn't demand a test, but, of course, every little bit is welcome, if you feel like it. Our test coverage is very bad, and this is one of the reasons why it's so hard to review PRs in a timely manner. You have to check that the code makes sense and doesn't have unwanted side-effects, and with no test coverage it's mostly a gamble...

@zyv zyv requested a review from egmontkob March 27, 2026 14:42
@peripherium peripherium force-pushed the fix/color-error-while-nocolor branch 2 times, most recently from 8abd9f1 to 5ae01ef Compare March 30, 2026 12:28
@peripherium
Copy link
Copy Markdown
Contributor Author

In this case, I wouldn't demand a test, but, of course, every little bit is welcome, if you feel like it. Our test coverage is very bad, and this is one of the reasons why it's so hard to review PRs in a timely manner. You have to check that the code makes sense and doesn't have unwanted side-effects, and with no test coverage it's mostly a gamble...

I took a quick look at this over the weekend and decided to add a test. It turned out to be fairly simple, and writing it was a nice way to better understand this part of the code.

@peripherium peripherium force-pushed the fix/color-error-while-nocolor branch 3 times, most recently from c6a2a27 to 97dd6e6 Compare March 30, 2026 14:29
@peripherium
Copy link
Copy Markdown
Contributor Author

I don't understand why my mc_skin_init() test fails on both Ubuntu and Fedora. Is there a way to look at the log somewhere?

@zyv
Copy link
Copy Markdown
Member

zyv commented Mar 30, 2026

I don't understand why my mc_skin_init() test fails on both Ubuntu and Fedora.

On Fedora, it's a simple formatting issue, and you have accidentally botched a symlink. You can see the log here:

https://github.com/MidnightCommander/mc/actions/runs/23750102108/job/69189411316?pr=5081

Is there a way to look at the log somewhere?

On Ubuntu, it's more interesting. Maybe something to do with mocking?

FAIL: common__mc_skin_init
==========================

Running suite(s): /lib/skin
Running suite /lib/skin
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:0: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:152:P:Core:skin_test:1: Passed
../../../../tests/lib/skin/common__mc_skin_init.c:152:P:Core:skin_test:2: Passed
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:3: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:152:P:Core:skin_test:4: Passed
../../../../tests/lib/skin/common__mc_skin_init.c:152:P:Core:skin_test:5: Passed
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:6: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:7: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:152:P:Core:skin_test:8: Passed
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:9: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:10: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:152:P:Core:skin_test:11: Passed
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:12: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:13: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:14: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:15: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:16: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:17: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
33%: Checks: 18, Failures: 12, Errors: 0
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:0: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:3: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:6: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:7: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:9: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:10: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:12: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:13: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:14: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:15: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:16: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
../../../../tests/lib/skin/common__mc_skin_init.c:145:F:Core:skin_test:17: mc_skin_init (data->skin_name, &mcerror) variable should be TRUE
Results for all suites run:
33%: Checks: 18, Failures: 12, Errors: 0
FAIL common__mc_skin_init (exit status: 1)

@peripherium peripherium force-pushed the fix/color-error-while-nocolor branch 2 times, most recently from 5f8b10e to 909c0dc Compare March 31, 2026 06:08
@peripherium
Copy link
Copy Markdown
Contributor Author

On Ubuntu, it's more interesting. Maybe something to do with mocking?

I've added a line to my test code (printf("MOCK: tty_use_256colors()\n");) that proves, the Ubuntu test ignores the "weak" attribute (MC_MOCKABLE). I'm currently comparing my test with other tests that mock functions. Any suggestions or ideas are welcome.

@peripherium peripherium force-pushed the fix/color-error-while-nocolor branch 8 times, most recently from f731395 to 09c916f Compare March 31, 2026 11:52
@peripherium peripherium force-pushed the fix/color-error-while-nocolor branch 20 times, most recently from 467d1eb to 24ae55a Compare April 2, 2026 09:18
@zyv zyv force-pushed the fix/color-error-while-nocolor branch from 24ae55a to 6dc6dd0 Compare April 5, 2026 06:56
@zyv zyv requested a review from mc-worker April 5, 2026 07:00
Copy link
Copy Markdown
Member

@zyv zyv left a comment

Choose a reason for hiding this comment

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

@peripherium I think that I've now fixed the CI and reverted all of your experimental changes. Please have another look.

The problem was that you failed to account for VPATH builds, and so your hacked skin loading wasn't working correctly. The other irritating problem with library linking order is due to #4806. I hope that one day I'll get enough time to fix this. Sorry that it has taken me so long.

@mc-worker @egmontkob, are you fine with the current state of the PR?

@zyv
Copy link
Copy Markdown
Member

zyv commented Apr 5, 2026

/rebase

Suppress the color capability warning when --nocolor is used.
Keep the warning if a skin is explicitly requested.

Signed-off-by: Manuel Einfalt <einfalt1@proton.me>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
@mc-butler mc-butler force-pushed the fix/color-error-while-nocolor branch from 32c7234 to ae89a8e Compare April 5, 2026 11:47
@zyv zyv merged commit b6012a2 into MidnightCommander:master Apr 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: skin Theming support and skin files prio: medium Has the potential to affect progress

Development

Successfully merging this pull request may close these issues.

--nocolor complains about not enough colors

3 participants