Skip to content

Several tests in "org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text" are flapping #106

Closed

Description

@laeubi

The test fails from one build to the other without any SWT code changes.

Activity

  1. SyntevoAlex commented on Jul 4, 2023

    @SyntevoAlex
    Member

    I have investigated that.

    All clipboard-related tests can fail, I myself seen these:

    Test_org_eclipse_swt_widgets_Text.test_consistency_Segments
    Test_org_eclipse_swt_widgets_Text.test_copy
    Test_org_eclipse_swt_widgets_Text.test_paste
    Test_org_eclipse_swt_widgets_Combo.test_consistency_Segments
    Test_org_eclipse_swt_widgets_Combo.test_copy
    Test_org_eclipse_swt_custom_CCombo.test_cut
    

    The failure is chance based, with around 1% chance.

    It's easy to reproduce by running this code:

    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout (new GridLayout (1, true));
    
    Text text = new Text(shell, 0);
    System.out.format("%X = handle%n", text.handle);
    
    shell.pack();
    shell.open();
    while (display.readAndDispatch()) {};
    
    for (int i = 0; i < 10000; i++) {
    	text.setText("01234567890");
    	text.setSelection(2, 5);
    	text.cut();
    	if (!text.getText().equals("01567890")) {
    		System.out.println("Error!");
    	}
    }
    
    while (!shell.isDisposed()) {
    	if (!display.readAndDispatch()) {
    		display.sleep();
    	}
    }
    
    display.dispose();

    I have debugged, the problem is that OpenClipboard() fails inside WINAPI handler for messages like WM_COPY or WM_CUT. Can be seen with WinDBG breakpoint: bp win32u!NtUserOpenClipboard+0x14 ".if (@rax == 1) {g}".

    I'm not exactly sure what causes the failure. It doesn't make sense that some other app repeatedly claims ownership of clipboard, but maybe that is indeed the case. Maybe when SWT copies something to clipboard, some other app checks that, and if SWT tries to copy again while app is checking, it fails. Getting a definitive answer would require kernel debugging, and I don't think the Issue is important enough to spend time on that.

  2. basilevs commented on Jan 27, 2024

    @basilevs
    Contributor

    https://github.com/eclipse-platform/eclipse.platform.swt/actions/runs/7674714373/job/20919789301

    org.junit.ComparisonFailure: expected:<[00000]> but was:<[]>
    	at org.junit.Assert.assertEquals(Assert.java:117)
    	at org.junit.Assert.assertEquals(Assert.java:146)
    	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text.test_copy(Test_org_eclipse_swt_widgets_Text.java:324)
    
  3. fedejeanne commented on Jun 18, 2024

    @fedejeanne
    Member

    Also failed in this run of #1265

    expected:<[00000]> but was:<[]>
    org.junit.ComparisonFailure: expected:<[00000]> but was:<[]>
    	at org.junit.Assert.assertEquals(Assert.java:117)
    	at org.junit.Assert.assertEquals(Assert.java:146)
    	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text.test_copy(Test_org_eclipse_swt_widgets_Text.java:343)
    ...
  4. changed the title [-]test_cut (org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text) is flapping[/-] [+]Several tests in "org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text" are flapping[/+] on Jun 18, 2024
  5. deepika-u commented on Jan 9, 2025

    @deepika-u
    Contributor

    Can this also be closed?
    As i see the tests pass now

    <testcase classname="org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text" name="test_cut" time="0.015"/>
    <testcase classname="org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text" name="test_consistency_Segments" time="0.073"/>
    <testcase classname="org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text" name="test_copy" time="0.016"/>
    <testcase classname="org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Text" name="test_paste" time="0.022"/>
    <testcase classname="org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo" name="test_consistency_Segments" time="0.053"/>
    <testcase classname="org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo" name="test_copy" time="0.006"/>
    <testcase classname="org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_CCombo" name="test_cut" time="0.006"/>
    

    From -> https://download.eclipse.org/eclipse/downloads/drops4/I20250108-1800/testresults/xml/org.eclipse.swt.tests_ep435I-unit-win32-x86_64-java21_win32.win32.x86_64_21.xml

  6. fedejeanne commented on Jan 13, 2025

    @fedejeanne
    Member

    The problem seems to be there still:

    image

    Or do you know of any fix @deepika-u ?

    To reproduce

    Let the test class run hundreds of times by making it parameterized

    @RunWith(Parameterized.class)
    public class Test_org_eclipse_swt_widgets_Text extends Test_org_eclipse_swt_widgets_Scrollable {
    
    ...
    
    @Parameters
    public static Collection<Integer> params() {
    	return  IntStream.range(1, 301).boxed().collect(Collectors.toList());
    }
    
    public Test_org_eclipse_swt_widgets_Text(Integer i) { }
    ...
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    junitJUnit test failure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions