Skip to content

Improve tests embebbing#40

Merged
Vladyslav-Kuksiuk merged 12 commits into
masterfrom
improve-tests-embebbing
May 28, 2026
Merged

Improve tests embebbing#40
Vladyslav-Kuksiuk merged 12 commits into
masterfrom
improve-tests-embebbing

Conversation

@Vladyslav-Kuksiuk
Copy link
Copy Markdown
Collaborator

@Vladyslav-Kuksiuk Vladyslav-Kuksiuk commented May 26, 2026

This PR improves pattern-based embedding by adding explicit multi-line matching for start, end and line patterns. Instead of requiring a single source line to identify a fragment boundary, patterns can now use \n to match consecutive source lines.

For example:

<embed-code
  file="$test/JunitTest.java"
  start="Test \n adds two values"
  end="assertEquals(2, value); \n }"
/>
```java
@Test
@DisplayName("adds two values")
void addsTwoValues() {
    int value = 1 + 1;

    assertEquals(2, value);
}
```

Each line in a multi-line pattern follows the same glob rules as regular one-line patterns, including ^ and $ for exact matching.

Spaces around \n are ignored.

Additional change: added possibility to write quote characters in patterns as \" instead of the XML entity &quot;.

Resolves #44.

@Vladyslav-Kuksiuk Vladyslav-Kuksiuk self-assigned this May 26, 2026
@Vladyslav-Kuksiuk Vladyslav-Kuksiuk marked this pull request as ready for review May 26, 2026 11:31
Copy link
Copy Markdown
Collaborator

@dmytro-kashcheiev dmytro-kashcheiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vladyslav-Kuksiuk LGTM with minor comment.

Comment thread test/resources/code/java/org/example/MultiLinePatternSample.java Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends embed-code’s glob-based matching to support multi-line start/end/line patterns separated by \n, and adds support for writing quotes in XML attributes as \" (converted to &quot; internally). It updates documentation and adds new test fixtures + test cases to validate the behavior.

Changes:

  • Add multi-line pattern parsing/matching for start, end, and line patterns using \n separators (with \\n for literal \n text).
  • Allow backslash-escaped quotes (\") in <embed-code ...> XML attributes by converting them to &quot; before XML unmarshalling.
  • Add new embedding/parsing tests and documentation examples; bump version to 1.2.1.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
embedding/parsing/pattern.go Adds multi-line pattern splitting and matching helpers.
embedding/parsing/instruction.go Implements multi-line matching for line, and multi-line-aware start/end matching.
embedding/parsing/xml_parse.go Preprocesses \" into &quot; prior to xml.Unmarshal.
embedding/parsing/instruction_test.go Adds tests for \" parsing and literal glob-character escaping.
embedding/embedding_test.go Adds end-to-end embedding tests covering multi-line patterns and literal \\n matching.
EMBEDDING.md Documents multi-line patterns and escaping rules (including \").
test/resources/docs/escaped-newline-pattern.md New doc fixture for multi-line start/end patterns.
test/resources/docs/escaped-newline-exact-pattern.md New doc fixture for exact (^...$) multi-line patterns.
test/resources/docs/escaped-newline-line-pattern.md New doc fixture for multi-line line patterns.
test/resources/docs/escaped-newline-literal-pattern.md New doc fixture for matching literal \\n text.
test/resources/code/java/org/example/MultiLinePatternSample.java New code fixture used by multi-line pattern embedding tests.
test/resources/code/java/literal-patterns.txt New text fixture for literal wildcard/caret/dollar matching tests.
main.go Bumps application version to 1.2.1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread embedding/parsing/instruction.go
Comment thread EMBEDDING.md Outdated
Comment thread embedding/parsing/pattern.go
@Vladyslav-Kuksiuk Vladyslav-Kuksiuk merged commit df092f4 into master May 28, 2026
3 checks passed
@Vladyslav-Kuksiuk Vladyslav-Kuksiuk deleted the improve-tests-embebbing branch May 28, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support embedding JUnit test methods

3 participants