refactor: keep compiler source standalone

Signed-off-by: Cole Speelman <crspeelman@gmail.com>
This commit is contained in:
2026-08-11 23:58:25 -04:00
parent 0941075baa
commit 7b839f8155
40 changed files with 130 additions and 1581 deletions
+2 -3
View File
@@ -63,10 +63,9 @@ func TestCommittedGoldenOutput(t *testing.T) {
if !ok {
t.Fatal("runtime.Caller failed")
}
root := filepath.Clean(filepath.Join(filepath.Dir(thisFile), "..", ".."))
sourcePath := filepath.Join(root, "examples", "eql-shaped", "views", "badge.sando")
sourcePath := filepath.Join(filepath.Dir(thisFile), "testdata", "golden", "basic.sando")
wantPath := sourcePath + ".go"
compiled, diagnostics := compileWithMapping(sourcePath, mustRead(t, sourcePath), "views/badge.sando")
compiled, diagnostics := compileWithMapping(sourcePath, mustRead(t, sourcePath), "internal/compiler/testdata/golden/basic.sando")
assertNoErrorDiagnostics(t, diagnostics)
if want := mustRead(t, wantPath); !bytes.Equal(compiled.Code, want) {
t.Fatalf("committed golden output is stale; run himesan generate\n--- got ---\n%s\n--- want ---\n%s", compiled.Code, want)
+7
View File
@@ -0,0 +1,7 @@
<?sando go
package golden
func Greeting(name string)
?>
<?# SPDX-License-Identifier: AGPL-3.0-only ?>
<p class="greeting">Hello, <?= name ?>.</p>
+37
View File
@@ -0,0 +1,37 @@
// Code generated by himesan; DO NOT EDIT.
// himesan:compiler 0.1.0-dev
// himesan:runtime-abi sando.v1
// himesan:source-sha256 f4ba01010ed5f5ba1e979702d82e95312bc0a4b13cc205c098926839be4ecb73
package golden
import (
__himesan_context "context"
__himesan_sando "gamertan.com/sandwich-hime/sando"
__himesan_io "io"
)
var _ = __himesan_sando.ABI
func Greeting(name string) __himesan_sando.Component {
return __himesan_sando.ComponentFunc(func(__himesan_render_context __himesan_context.Context, __himesan_writer __himesan_io.Writer) error {
_ = __himesan_render_context
//line internal/compiler/testdata/golden/basic.sando:5:3
if __himesan_error := __himesan_sando.WriteString(__himesan_writer, "\n"); __himesan_error != nil {
return __himesan_error
}
//line internal/compiler/testdata/golden/basic.sando:6:46
if __himesan_error := __himesan_sando.WriteString(__himesan_writer, "\n<p class=\"greeting\">Hello, "); __himesan_error != nil {
return __himesan_error
}
//line internal/compiler/testdata/golden/basic.sando:7:32
if __himesan_error := __himesan_sando.WriteText(__himesan_writer, (name)); __himesan_error != nil {
return __himesan_error
}
//line internal/compiler/testdata/golden/basic.sando:7:39
if __himesan_error := __himesan_sando.WriteString(__himesan_writer, ".</p>\n"); __himesan_error != nil {
return __himesan_error
}
return nil
})
}