metanorma / metanorma-plugin-lutaml

Metanorma plugin: access LutaML objects from within a Metanorma document
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

spec file is much to slow #142

Closed opoudjis closed 1 week ago

opoudjis commented 1 week ago

spec/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor_spec.rb is so structured that this gem's rake job is taking literally TWO HOURS to run on Github Actions:

https://github.com/metanorma/metanorma-plugin-lutaml/actions/runs/10628356603

This is because it is recompiling the test Asciidoctor document for each and every instance of include_example. There are dozens of them. And the test document is unchanged across a dozen or more executions in each test.

This needs to be sped up. In cases like:

describe "#process" do
    let(:example_file) { fixtures_path("large_test.xmi") }
    let(:config_file) do
      fixtures_path("lutaml_uml_datamodel_description_config.yml")
    end

    context "when there is an options file" do
      let(:input) do
        <<~TEXT
...
        TEXT
      end
      subject (:output) { metanorma_process(input) }

      # @note datamodel_description_sections.xml
      context "correctly renders input" do
        # expect(xml_string_content(metanorma_process(input)))
        #     .to(be_equivalent_to(xml_string_content(output)))

        include_examples "should contain preface"
        include_examples "should contain sections"
        include_examples "should contain text", "Diagram text"
        include_examples "should contain text", "my text"
        include_examples "should contain text", "mine text"
        include_examples "should contain package content", "Another"
        include_examples "should contain table title"
        include_examples "should contain table headers"
        include_examples "should contain package content", "CityGML"
        include_examples "should contain text after package",
                         "Additional information",
                         "text after Another package"
        include_examples "should contain text after package",
                         "Additional information",
                         "text after CityGML package"
        include_examples "should contain footer text"

the step metanorma_process(input) should be run ONLY ONCE, and the include_examples should be replaced by scanning the IDENTICAL output string, and checking it for inclusions:

context "correctly renders input" do
  output = metanorma_process(input)
  expect(output).to include "preface"
  expect(output).to include "sections"

and whatever other substitutions you need to do to make it work.