slim icon indicating copy to clipboard operation
slim copied to clipboard

test_embedded_engines error in x86_64 and riscv64

Open gyx47 opened this issue 9 months ago • 1 comments

Description:

There is a problem with the test code of the ruby-slim-5.2.1-2 package. The package build failed under both the riscv64 and x86-64 architectures. According to the log output, the /core/test_embedded_engines test file reported an error when entering the test phase.

1) Failure:
TestSlimEmbeddedEngines#test_render_with_markdown [test/core/test_embedded_engines.rb:27]:
--- expected
+++ actual
@@ -1,12 +1,7 @@
-"<h1 id=\"header\">Header</h1>
-<p>Hello from Markdown!</p>
-
+"<p>#Header Hello from Markdown!</p>
 <p>3</p>
-
 <p><a href=\"#2\">1</a></p>
-
 <ul>
-  <li>one</li>
-  <li>two</li>
-</ul>
-"
+<li>one</li>
+<li>two</li>
+</ul>"
  • package version(s):ruby-slim-5.2.1-2
  • config and/or log files:

ruby-slim-5.2.1-2-riscv64-check.log

ruby-slim-5.2.1-2-x86_64-check.log

My operating environment is an x86-64 environment virtual machine and a riscv64 chroot environment of the arch architecture of Windows WSL. The process is as follows:

  1. I cloned your project and installed the dependencies
  2. run MT_COMPAT="true" GEM_HOME="tmp_install/${_gemdir}" rake test

3.wait for it and found the error

Patch

I modified the test file. Here are my ideas for modification:

This is the relevant code for the error in the test of /test/core/test_embedded_engines.rb

def test_render_with_markdown
    source = %q{
markdown:
  #Header
  Hello from #{"Markdown!"}

  #{1+2}

  [#{1}](#{"#2"})

  * one
  * two
}
    if ::Tilt['md'].name =~ /Redcarpet/
      # redcarpet
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source
    elsif ::Tilt['md'].name =~ /RDiscount/
      # rdiscount
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n\n", source
    else
      # kramdown, :auto_ids by default
      assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n  <li>one</li>\n  <li>two</li>\n</ul>\n", source

      Slim::Embedded.with_options(markdown: {auto_ids: false}) do
        assert_html "<h1>Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n  <li>one</li>\n  <li>two</li>\n</ul>\n", source
      end

      assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n  <li>one</li>\n  <li>two</li>\n</ul>\n", source
    end
  end

After debugging, I found that This test example has a formatting problem. The header is followed by #, which the md document cannot recognize, so the conversion to the html document is also wrong. The actual and expected values ​​of the <li> list are only one space indented, which has no effect on the html conversion. Maybe this test file can be looser, or the indentation can be manually added in the function implementation document. I change the test file

def test_render_with_markdown
    source = %q{
markdown:
  # Header
  Hello from #{"Markdown!"}

  #{1+2}

  [#{1}](#{"#2"})

  * one
  * two
}
    if ::Tilt['md'].name =~ /Redcarpet/
      # redcarpet
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source
    elsif ::Tilt['md'].name =~ /RDiscount/
      # rdiscount
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n\n", source
    else
      # kramdown, :auto_ids by default
      assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n<p>3</p>\n<p><a href=\"#2\">1</a></p>\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>", source

      Slim::Embedded.with_options(markdown: {auto_ids: false}) do
        assert_html "<h1>Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source
      end

      assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n<p>3</p>\n<p><a href=\"#2\">1</a></p>\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source
    end
  end

The previous error was solved, but another error was followed

 1) Failure:
TestSlimEmbeddedEngines#test_render_with_markdown [test/core/test_embedded_engines.rb:30]:
--- expected
+++ actual
@@ -1,12 +1,8 @@
-"<h1>Header</h1>
+"<h1 id=\"header\">Header</h1>
 <p>Hello from Markdown!</p>
-
 <p>3</p>
-
 <p><a href=\"#2\">1</a></p>
-
 <ul>
 <li>one</li>
 <li>two</li>
-</ul>
-"
+</ul>"

and the code is

 Slim::Embedded.with_options(markdown: {auto_ids: false}) do
        assert_html "<h1>Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<p><a href=\"#2\">1</a></p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source

I think the function to make the auto_ids: false ,may have some problems that need further Improvements.

Do you think this is a good career change? If you think it is, I will open a PR.

gyx47 avatar Mar 07 '25 16:03 gyx47

@gyx47 please try with ruby-slim 5.2.1-3 which removed ruby-pandoc-ruby from the test environment and instead ruby-kramdown is used which produces the expected output. Which would make this a packaging issue rather than issue with slim-template.

loqs avatar Apr 09 '25 01:04 loqs