From 22d39cf13dd809a1e784d73149935a31f8873e27 Mon Sep 17 00:00:00 2001 From: Vladyslav Kuksiuk Date: Thu, 21 May 2026 14:54:28 +0200 Subject: [PATCH 1/3] Fix the `nested dir embedding` test. --- embedding/embedding_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/embedding/embedding_test.go b/embedding/embedding_test.go index d30a421..ab05744 100644 --- a/embedding/embedding_test.go +++ b/embedding/embedding_test.go @@ -256,12 +256,9 @@ var _ = Describe("Embedding", func() { )) }) - // TODO:olena-zmiiova:https://github.com/SpineEventEngine/embed-code/issues/65 It("should successfully embed to a file in a nested dir", func() { - Skip( - "Temporarily disabled, see " + - "[issue #65](https://github.com/SpineEventEngine/embed-code/issues/65).", - ) + config.CodeRoots = _type.NamedPathList{_type.NamedPath{Path: "../test/resources/code/kotlin"}} + config.DocIncludes = []string{"nested-dir-1/nested-dir-2/nested-dir-doc.md"} docPath := fmt.Sprintf("%s/nested-dir-1/nested-dir-2/nested-dir-doc.md", config.DocumentationRoot) processor := embedding.NewProcessor(docPath, config) From 5f8b5330d8b025adb1e4f4ffd98c98ed17ba03f4 Mon Sep 17 00:00:00 2001 From: Vladyslav Kuksiuk Date: Thu, 21 May 2026 15:00:09 +0200 Subject: [PATCH 2/3] Improve transition map usage. --- embedding/embedding_test.go | 5 ----- embedding/processor.go | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/embedding/embedding_test.go b/embedding/embedding_test.go index ab05744..f2857c3 100644 --- a/embedding/embedding_test.go +++ b/embedding/embedding_test.go @@ -83,12 +83,7 @@ var _ = Describe("Embedding", func() { Expect(processor.IsUpToDate()).Should(BeTrue()) }) - // TODO:olena-zmiiova:https://github.com/SpineEventEngine/embed-code/issues/59 It("should have error as it has invalid transition map", func() { - Skip( - "Temporarily disabled, see " + - "[issue #59](https://github.com/SpineEventEngine/embed-code/issues/59).", - ) docPath := fmt.Sprintf("%s/split-lines.md", config.DocumentationRoot) falseTransitions := parsing.TransitionMap{ diff --git a/embedding/processor.go b/embedding/processor.go index df99270..764a57a 100644 --- a/embedding/processor.go +++ b/embedding/processor.go @@ -291,7 +291,7 @@ func unacceptedTransitionError(context parsing.Context) error { // it successfully moved to the next state and returns the new state. func (p Processor) moveToNextState(state *parsing.State, context *parsing.Context) ( bool, *parsing.State, error) { - for _, nextState := range parsing.Transitions[*state] { + for _, nextState := range p.TransitionsMap[*state] { if nextState.Recognize(*context) { err := nextState.Accept(context, p.Config) if err != nil { From 71be0be7d12b46fa6e35539dbede3befdffc6123 Mon Sep 17 00:00:00 2001 From: Vladyslav Kuksiuk Date: Thu, 21 May 2026 17:07:53 +0200 Subject: [PATCH 3/3] Add one line embedding test. --- embedding/parsing/instruction_test.go | 14 ++++++++++++++ .../code/java/examples/hello/build.gradle | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/resources/code/java/examples/hello/build.gradle diff --git a/embedding/parsing/instruction_test.go b/embedding/parsing/instruction_test.go index 8361dd0..139dc82 100644 --- a/embedding/parsing/instruction_test.go +++ b/embedding/parsing/instruction_test.go @@ -308,6 +308,20 @@ var _ = Describe("Instruction", func() { Expect(actualLines[1]).Should(MatchRegexp(expectedLastLinePattern)) }) + It("should embed one line when start and end globs match the same line", func() { + instructionParams := TestInstructionParams{ + startGlob: "*spine.enableJava()*", + endGlob: "*.server()", + } + + actualLines := getXMLExtractionContent( + "examples/hello/build.gradle", instructionParams, config) + + Expect(actualLines).Should(Equal([]string{ + "spine.enableJava().server()", + })) + }) + It("should successfully parse XML by globs with line starts", func() { instructionParams := TestInstructionParams{ startGlob: "^foo", diff --git a/test/resources/code/java/examples/hello/build.gradle b/test/resources/code/java/examples/hello/build.gradle new file mode 100644 index 0000000..fd31569 --- /dev/null +++ b/test/resources/code/java/examples/hello/build.gradle @@ -0,0 +1,11 @@ +plugins { + id 'java' +} + +spine.enableJava().server() + +tasks.register('hello') { + doLast { + println 'Hello' + } +}