Compiler tests properly add extension to obj files

This commit is contained in:
Sasha Koshka 2024-03-30 23:01:38 -04:00
parent 810175b6c9
commit 93d4aea1b1
2 changed files with 6 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import "path/filepath"
import "git.tebibyte.media/fspl/fspl/entity"
import "git.tebibyte.media/fspl/fspl/errors"
import "git.tebibyte.media/fspl/fspl/testcommon"
import "git.tebibyte.media/fspl/fspl/generator/native"
//go:embed all:test-data/*
var testData embed.FS
@ -27,6 +28,8 @@ func defaultCompiler () *Compiler {
comp.Resolver.FS = testData
comp.Filetype = FiletypeObject
comp.Debug = true
nativeTarget := native.NativeTarget()
comp.Target = &nativeTarget
return comp
}
@ -50,7 +53,7 @@ func compileDependency (
if !ok {
test.Fatal("could not generate nickname for", address)
}
comp.Output = filepath.Join(temp, nickname)
comp.Output = filepath.Join(temp, FiletypeObject.Extend(*comp.Target, nickname))
// compile to object file
err := comp.CompileUnit(address)
@ -79,7 +82,7 @@ func testUnit (
test.Log("COMPILER LOG (main unit):\n" + compOutputBuilder.String())
}
comp.Writer = compOutputBuilder
comp.Output = filepath.Join(temp, "output.o")
comp.Output = filepath.Join(temp, FiletypeObject.Extend(*comp.Target, "output"))
// compile to object file
err := comp.CompileUnit(address)

View File

@ -34,6 +34,7 @@ func (this *Compiler) CompileUnit (address entity.Address) error {
// if the format isn't specified, try to get it from the filename
// extension of the input. if that isn't specified, default to .o
if this.Filetype == FiletypeUnknown {
this.Debugln("filetype was not specified")
if this.Output == "" {
this.Filetype = FiletypeObject
} else {