Skip to content

added a copy button which copies all the errors and traceback to clip…#25979

Merged
chennes merged 7 commits intoFreeCAD:mainfrom
Mr-Rahul-Paul:bug/25599/test-copy-failing-list
Jan 12, 2026
Merged

added a copy button which copies all the errors and traceback to clip…#25979
chennes merged 7 commits intoFreeCAD:mainfrom
Mr-Rahul-Paul:bug/25599/test-copy-failing-list

Conversation

@Mr-Rahul-Paul
Copy link
Contributor

Fixes #25599

This PR fixes #25599 by adding a "Copy" button to the Unit Test dialog, allowing users to copy the details of failing tests directly to the clipboard.

Before

No easy way to extract the list of Errors from the UI.
image

After

A new "Copy" button is added below the Close button. On clicking, it copies errors and traceback(s) to the system clipboard.
image

How I reproduced the Issue

  1. Open the demo file AssemblyExample.FCStd.
  2. Enable the Test Framework workbench from Preferences.
  3. Run Self-test → TestApp.All.
  4. Click Start and wait for failures to appear in the list.

Changes done

  • Added "Copy" button in UnitTest.ui file with name "copyButton"
  • Declared onCopyButtonClicked() function in UnitTestImp.h
  • clicking 'copybutton' calls 'onCopyButtonClicked()' which copies the error(s) to clipboard

Remarks

  • the logic used in onCopyButtonClicked() is that function iterates through the list of failures (treeViewFailure), extracting both the error names and the tracebacks, appending them to a string variable which is then copied to the clipboard.
  • I have tried my best to ensure all new function names (like onCopyButtonClicked) and variable naming conventions follow the existing patterns to maintain consistency

@github-actions github-actions bot added the Mod: Test Related to the Test Workbench label Dec 5, 2025
@Mr-Rahul-Paul Mr-Rahul-Paul force-pushed the bug/25599/test-copy-failing-list branch 2 times, most recently from 21117df to 108cc1c Compare December 6, 2025 06:45
@maxwxyz maxwxyz added this to the 1.2 milestone Dec 6, 2025
@maxwxyz maxwxyz moved this from Queue to Merge Meeting in Merge Queue Dec 6, 2025
@maxwxyz maxwxyz added the Type: Feature FR for improvements or new features label Dec 6, 2025
@xtemp09
Copy link
Contributor

xtemp09 commented Dec 6, 2025

Is there a reason to create a MessageBox to show that everything is copied? Would it be better to change the title temporarily, like it is done in the About dialog? The same goes to the case if the text is empty. If there is nothing to copy, why bother to show a MessageBox?

Why is double "\n" added? Is it more beneficial than one?

Is the Copy button suitable to be near the Close button? I think that it is ought to be far to avoid accidental activation.

@xtemp09
Copy link
Contributor

xtemp09 commented Dec 6, 2025

<string>&amp;Copy </string>

I think that the ampersand before C must be removed, since it is present in the Close button's text.

Why does this string end with space?

@luzpaz
Copy link
Contributor

luzpaz commented Dec 6, 2025

Thanks for addressing this long standing issue (it existed before #25599 was opened)

@Mr-Rahul-Paul
Copy link
Contributor Author

Hey @xtemp09

Is there a reason to create a MessageBox to show that everything is copied? Would it be better to change the title temporarily, as it is done in the About dialog? The same goes to the case if the text is empty. If there is nothing to copy, why bother to show a MessageBox?

I am also a freelance 3d artist. So I based it on Blender's behaviour. In Blender, there is often a box that pops up in the bottom when some certain tasks are performed, so I thought adding a pop-up to notify would be a good idea. (this can be changed if the maintainers don't like it.)

eg (blender screenshot):
image

Why is double "\n" added? Is it more beneficial than one?

I noticed this pattern elsewhere in the codebase
msg += "\n\n";
So I kept it consistent. Happy to change to single \n if preferred.

I think that the ampersand before C must be removed, since it is present in the Close button's text.

I tried to match the pattern of the code in the file UnitTesImp.cpp (so as not to make a mess and keep the code structure consistent)

Why does this string end with space?

Agreed, that should be removed.

@xtemp09
Copy link
Contributor

xtemp09 commented Dec 6, 2025

I think that the ampersand before C must be removed, since it is present in the Close button's text.

I tried to match the pattern of the code in the file UnitTesImp.cpp (so as not to make a mess and keep the code structure consistent)

Usage of amersand creates a mnemonic shortcut.1 Perhaps, the ampersand in the "&Close" button must be removed, for consistency.


I am also a freelance 3d artist. So I based it on Blender's behaviour. In Blender, there is often a box that pops up in the bottom when some certain tasks are performed, so I thought adding a pop-up to notify would be a good idea. (this can be changed if the maintainers don't like it.)

I think that a pop-up notification is the best option along with a message in the status bar. =) But, the About dialog already has a button to copy to clipboard. I think it would be beneficial to mimic its behavior.

I think also that placing the Copy button next to the Close button is not a good idea. In my opinion, they should be separated with a separator or placed in different locations.

Footnotes

  1. https://doc.qt.io/archives/qt-5.15/qshortcut.html#details

@Mr-Rahul-Paul Mr-Rahul-Paul force-pushed the bug/25599/test-copy-failing-list branch 2 times, most recently from b19baba to 7a5168a Compare December 6, 2025 17:13
@Mr-Rahul-Paul
Copy link
Contributor Author

Mr-Rahul-Paul commented Dec 6, 2025

  • Removed ampersand from 'Close'
  • removed space from copy button
  • after copying the Errors , the message shows up in the status bar (below the error tree) instead of a popup
  • removed an unwanted header
  • moved copy button on top of Help button

awaiting feedback from maintainers

@xtemp09
Copy link
Contributor

xtemp09 commented Dec 6, 2025

It appears the tab order needs to be adjusted.

@chennes
Copy link
Member

chennes commented Dec 7, 2025

Thanks for the PR, @Mr-Rahul-Paul (and thanks @xtemp09 for the quick review). @FreeCAD/design-working-group any opinion on this button layout?

@maxwxyz maxwxyz added Requires: UI/UX review Issue/PR to be reviewed in terms of UI/UX by the Design Working Group or under refinement. Approved: UI/UX The Issue/PR was reviewed in terms of UI/UX and approved by the Design Working Group and removed Requires: UI/UX review Issue/PR to be reviewed in terms of UI/UX by the Design Working Group or under refinement. labels Dec 7, 2025
@Mr-Rahul-Paul
Copy link
Contributor Author

To keep things clear this is what the UI look like after the review and changes
image

@Mr-Rahul-Paul
Copy link
Contributor Author

@chennes any feed-back from you is appreciated

@maxwxyz maxwxyz moved this from Merge Meeting to Approved in Merge Queue Jan 5, 2026
@chennes chennes self-assigned this Jan 5, 2026
@maxwxyz maxwxyz force-pushed the bug/25599/test-copy-failing-list branch from 0f72e87 to 10c4de1 Compare January 8, 2026 17:47
@chennes chennes force-pushed the bug/25599/test-copy-failing-list branch from 10c4de1 to 4b521ef Compare January 12, 2026 03:32
Copy link
Member

@chennes chennes left a comment

Choose a reason for hiding this comment

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

I've made a couple of changes

QString text;
QTreeWidgetItemIterator it(ui->treeViewFailure);
while (*it) {
text += (*it)->data(0, Qt::UserRole).toString() + "\n\n";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
text += (*it)->data(0, Qt::UserRole).toString() + "\n\n";
text += (*it)->data(0, Qt::UserRole).toString() + QStringLiteral("\n\n");

<tabstop>helpButton</tabstop>
<tabstop>aboutButton</tabstop>
<tabstop>closeButton</tabstop>
<tabstop>copyButton</tabstop>
Copy link
Member

Choose a reason for hiding this comment

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

This should now be above the help button.

@chennes chennes enabled auto-merge (squash) January 12, 2026 03:33
@chennes chennes disabled auto-merge January 12, 2026 03:33
@chennes chennes enabled auto-merge (squash) January 12, 2026 03:34
@chennes chennes merged commit a628391 into FreeCAD:main Jan 12, 2026
12 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Merge Queue Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved: UI/UX The Issue/PR was reviewed in terms of UI/UX and approved by the Design Working Group Mod: Test Related to the Test Workbench Type: Feature FR for improvements or new features

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Test: Not possible to copy the list of failing tests

5 participants