mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package tsbaseline
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/microsoft/typescript-go/internal/core"
|
|
"github.com/microsoft/typescript-go/internal/testutil/baseline"
|
|
"github.com/microsoft/typescript-go/internal/testutil/harnessutil"
|
|
"github.com/microsoft/typescript-go/internal/tspath"
|
|
)
|
|
|
|
func DoSourcemapRecordBaseline(
|
|
t *testing.T,
|
|
baselinePath string,
|
|
header string,
|
|
options *core.CompilerOptions,
|
|
result *harnessutil.CompilationResult,
|
|
harnessSettings *harnessutil.HarnessOptions,
|
|
opts baseline.Options,
|
|
) {
|
|
actual := baseline.NoContent
|
|
if options.SourceMap.IsTrue() || options.InlineSourceMap.IsTrue() || options.DeclarationMap.IsTrue() {
|
|
record := removeTestPathPrefixes(result.GetSourceMapRecord(), false /*retainTrailingDirectorySeparator*/)
|
|
if !(options.NoEmitOnError.IsTrue() && len(result.Diagnostics) > 0) && len(record) > 0 {
|
|
actual = record
|
|
}
|
|
}
|
|
|
|
if tspath.FileExtensionIsOneOf(baselinePath, []string{tspath.ExtensionTs, tspath.ExtensionTsx}) {
|
|
baselinePath = tspath.ChangeExtension(baselinePath, ".sourcemap.txt")
|
|
}
|
|
|
|
baseline.Run(t, baselinePath, actual, opts)
|
|
}
|