GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Multiple spaces are replaced by single spaces in failure message · Issue #140 · utPLSQL/utPLSQL-SQLDeveloper

Multiple spaces are replaced by single spaces in failure message #140

New issue
Copy link
New issue
Copy link
Closed
Closed
Multiple spaces are replaced by single spaces in failure message#140
Copy link
Assignees
PhilippSalvisberg
Labels
bug
Milestone
v1.4.0

Description

@erikvanroon
erikvanroon
opened on Jan 6, 2022
Issue body actions

When the actual or expected value has multiple consecutive spaces and the test fails, the message on the failures tab shows both values with all multi-spaces replaced by a single one.
(See test script below)

This is annoying because at first I couldn't figure out why a test was failing because the message showed identical strings for actual and expected.
Running the test from SQLcl showed that actual had an extra space which isn't visible in feedback from the plugin.

Test Suite to reproduce

create or replace package ut_spaces
authid definer
is
    -- %suite(Test Plugin Output)

    -- %context(Multiple spaces in values)

        -- %test(Multiple spaces in actual)
        procedure multi_space_actual;

        -- %test(Multiple spaces in expect)
        procedure multi_space_expect;

    -- %endcontext

end ut_spaces;
/

create or replace package body ut_spaces
is

    -- Multiple spaces in actual
    procedure multi_space_actual
    is
        l_expect   varchar2(100);
        l_actual   varchar2(100);
    begin
        l_expect := 'This line has spaces';
        l_actual := 'This          line          has          spaces';

        ut.expect(l_actual).to_equal(l_expect);
    end;


    -- Multiple spaces in expect
    procedure multi_space_expect
    is
        l_expect   varchar2(100);
        l_actual   varchar2(100);
    begin
        l_expect := 'This          line          has          spaces';
        l_actual := 'This line has spaces';

        ut.expect(l_actual).to_equal(l_expect);
    end;

end ut_spaces;
/

In SQL Developer plugin
Running hese tests the plugin will report on the Failures tab:

Actual: 'This line has spaces' (varchar2) was expected to equal: 'This line has spaces' (varchar2)
at "ERO.UT_SPACES.MULTI_SPACE_ACTUAL", line 13 ut.expect(l_actual).to_equal(l_expect);

Note how all multiple spaces have been replaced by single spaces.

In SQLcl

Running the tests in SQLcl does show the multiple spaces
ERO@EVROCS>exec ut.run ('ut_spaces')
Test Plugin Output
  Multiple spaces in values
    Multiple spaces in actual [,481 sec] (FAILED - 1)
    Multiple spaces in expect [,004 sec] (FAILED - 2)

Failures:

  1) multi_space_actual
      Actual: 'This          line          has          spaces' (varchar2) was expected to equal: 'This line has spaces' (varchar2)
      at "ERO.UT_SPACES.MULTI_SPACE_ACTUAL", line 13 ut.expect(l_actual).to_equal(l_expect);

  2) multi_space_expect
      Actual: 'This line has spaces' (varchar2) was expected to equal: 'This          line          has          spaces' (varchar2)
      at "ERO.UT_SPACES.MULTI_SPACE_EXPECT", line 26 ut.expect(l_actual).to_equal(l_expect);

Finished in ,487971 seconds
2 tests, 2 failed, 0 errored, 0 disabled, 0 warning(s)


PL/SQL procedure successfully completed.

Activity

  1. PhilippSalvisberg commented on Jan 6, 2022

    @PhilippSalvisberg
    PhilippSalvisberg
    on Jan 6, 2022
    Member
    More actions

    Thanks @erikvanroon for reporting this issue. I can reproduce it easily with your test case.

    I'm using HTML to handle links in the field. So the content looks in my case as follows (PLSCOPE instead of ERO schema):

    <html>
    	<head>
    		<style type="text/css">
    			body, p {font-family: Dialog; font-size: 1.0em; line-height: 1.1em; margin-top: 0px; margin-bottom: 0px;}
    		</style>
    	</head>
    	<body>
    		<p>Actual: &#39;This          line          has          spaces&#39; (varchar2) was expected to equal: &#39;This line has spaces&#39; (varchar2)</p>
    <p>at <a href="UNKNOWN/PLSCOPE/UT_SPACES/13">&quot;PLSCOPE.UT_SPACES.MULTI_SPACE_ACTUAL&quot;, line 13</a> ut.expect(l_actual).to_equal(l_expect);</p>
    
    	</body>
    </html>
    

    This HTML code does not preserve whitespace. That's a bug.

  2. PhilippSalvisberg
    self-assigned this
    on Jan 6, 2022
  3. PhilippSalvisberg
    added
    bug
    on Jan 6, 2022
  4. PhilippSalvisberg commented on Jan 6, 2022

    @PhilippSalvisberg
    PhilippSalvisberg
    on Jan 6, 2022
    Member
    More actions

    Implementation note:

    • Try if this works in Swing: https://stackoverflow.com/questions/8994516/html-css-best-practice-for-preserving-white-space-on-certain-elements .

    • To be included here:

      utPLSQL-SQLDeveloper/sqldev/src/main/java/org/utplsql/sqldev/ui/runner/RunnerPanel.java

      Lines 478 to 495 in 77f9f0b

      private String getHtml(final String text) {
      StringBuilder sb = new StringBuilder();
      sb.append("<html>\n");
      sb.append("\t<head>\n");
      sb.append("\t\t<style type=\"text/css\">\n");
      sb.append("\t\t\tbody, p {font-family: ");
      sb.append(testOwnerTextField.getFont().getFamily());
      sb.append("; font-size: 1.0em; line-height: 1.1em; margin-top: 0px; margin-bottom: 0px;}\n");
      sb.append("\t\t</style>\n");
      sb.append("\t</head>\n");
      sb.append("\t<body>\n");
      sb.append("\t\t");
      sb.append(getLinkedAndFormattedText(text));
      sb.append('\n');
      sb.append("\t</body>\n");
      sb.append("</html>\n");
      return sb.toString();
      }

  5. PhilippSalvisberg
    added this to the v1.4.0 milestone on Jan 6, 2022
  6. PhilippSalvisberg
    added a commit that references this issue on Jan 6, 2022

    fixes #140 - Do not suppress multiple consecutive spaces

    This issue will close once commit dde8e11 is merged into the 'main' branch.
    dde8e11
  7. PhilippSalvisberg
    closed this as completedin dde8e11on Jan 6, 2022
  8. PhilippSalvisberg
    added a commit that references this issue on Jan 6, 2022

    Merge pull request #141 from utPLSQL/bugfix/issue-140-preserve-ws

    cbf1cd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @PhilippSalvisberg
    PhilippSalvisberg

Labels

bug

Type

No type

Projects

No projects

    Milestone

    • v1.4.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.