Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing of generated XMIR is not using our "lints" #938

Closed
yegor256 opened this issue Dec 3, 2024 · 8 comments
Closed

testing of generated XMIR is not using our "lints" #938

yegor256 opened this issue Dec 3, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request soon This issue will be solved soon

Comments

@yegor256
Copy link
Member

yegor256 commented Dec 3, 2024

I suggest using org.eolang:lints library (https://github.com/objectionary/lints), which may help JEO validate all XMIR documents generated, for their validity:

import com.jcabi.xml.StrictXML;
import org.eolang.lints.Program;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

final class Foo {
  @Test
  void testValidProgram() {
    Assertions.assertTrue(
      new Program(
        new StrictXML("<program/>")
      ).defects().empty()
    );
  }
}

This way, you will be assured that XMIR is generated strictly by the rules.

@yegor256
Copy link
Member Author

yegor256 commented Dec 3, 2024

@volodya-lombrozo please, check

@volodya-lombrozo
Copy link
Member

@yegor256 It's a good thing actually. Thank you. I will try.

@volodya-lombrozo volodya-lombrozo self-assigned this Dec 3, 2024
@volodya-lombrozo volodya-lombrozo added enhancement New feature or request soon This issue will be solved soon labels Dec 3, 2024
@yegor256
Copy link
Member Author

yegor256 commented Dec 3, 2024

@volodya-lombrozo pay attention that StrictXML will require you to have the following XMIR (xsi:xsi:noNamespaceSchemaLocation is mandatory):

<program xsi:noNamespaceSchemaLocation="https://www.eolang.org/xsd/XMIR-0.45.0.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <objects>
    [...]
  </objects>
</program>

You can see how we build it using Xembly, here: https://github.com/objectionary/eo/blob/master/eo-parser/src/main/java/org/eolang/parser/DrProgram.java (maybe you can simply reuse this DrProgram class)

@volodya-lombrozo
Copy link
Member

@yegor256 Could you help me with objectionary/lints usage please? I'm confused with all the new abstractions over xmir checking.

What should I use to verify the generated xmir:

new StrictXmir(res).inner()

or

new Program(new StrictXmir(res)).defects()

or

new Program(new StrictXML(res)).defects()

?

@yegor256
Copy link
Member Author

@volodya-lombrozo while all three are valid, this would be the best choice:

new Program(new StrictXmir(res)).defects()

This way you will:

  1. detect XSD errors
  2. detect linting defects
  3. avoid network interations, as much as it's possible

@volodya-lombrozo
Copy link
Member

@yegor256 Thank you. Understood.

volodya-lombrozo added a commit to volodya-lombrozo/jeo-maven-plugin that referenced this issue Dec 27, 2024
volodya-lombrozo added a commit to volodya-lombrozo/jeo-maven-plugin that referenced this issue Dec 28, 2024
volodya-lombrozo added a commit to volodya-lombrozo/jeo-maven-plugin that referenced this issue Dec 28, 2024
@volodya-lombrozo
Copy link
Member

@yegor256 Still an issue? objectionary/lints was incorporated into the plugin starting from 0.7.0 version.

@yegor256
Copy link
Member Author

@volodya-lombrozo perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request soon This issue will be solved soon
Projects
None yet
Development

No branches or pull requests

2 participants