fix: Fixes generating html conversion.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
@_spi(Internal) import ConfigurationClient
|
||||
@_spi(Internal) import PandocClient
|
||||
import PlaybookClient
|
||||
import Testing
|
||||
import TestSupport
|
||||
import Testing
|
||||
|
||||
@Suite("PandocClientTests")
|
||||
struct PandocClientTests: TestCase {
|
||||
@@ -13,12 +13,12 @@ struct PandocClientTests: TestCase {
|
||||
|
||||
static let expectedIncludeInHeaders = [
|
||||
"--include-in-header=/project/.build/head.tex",
|
||||
"--include-in-header=/project/.build/footer.tex"
|
||||
"--include-in-header=/project/.build/footer.tex",
|
||||
]
|
||||
|
||||
static let expectedFiles = [
|
||||
"/project/.build/Report.md",
|
||||
"/project/.build/Definitions.md"
|
||||
"/project/.build/Definitions.md",
|
||||
]
|
||||
|
||||
static var sharedRunOptions: PandocClient.RunOptions {
|
||||
@@ -49,7 +49,8 @@ struct PandocClientTests: TestCase {
|
||||
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).tex")
|
||||
|
||||
} assert: { output in
|
||||
let expected = ["pandoc"]
|
||||
let expected =
|
||||
["pandoc"]
|
||||
+ Self.expectedIncludeInHeaders
|
||||
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).tex"]
|
||||
+ Self.expectedFiles
|
||||
@@ -71,10 +72,11 @@ struct PandocClientTests: TestCase {
|
||||
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).html")
|
||||
|
||||
} assert: { output in
|
||||
let expected = ["pandoc"]
|
||||
+ Self.expectedIncludeInHeaders
|
||||
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).html"]
|
||||
+ Self.expectedFiles
|
||||
let expected = [
|
||||
"pandoc",
|
||||
"--output=\(Self.outputDirectory)/\(Self.defaultFileName).html",
|
||||
"\(Self.projectDirectory)/.build/Report.tex",
|
||||
]
|
||||
|
||||
#expect(output.arguments == expected)
|
||||
}
|
||||
@@ -83,7 +85,7 @@ struct PandocClientTests: TestCase {
|
||||
@Test(
|
||||
arguments: [
|
||||
nil,
|
||||
"lualatex"
|
||||
"lualatex",
|
||||
]
|
||||
)
|
||||
func generatePdf(pdfEngine: String?) async throws {
|
||||
@@ -94,11 +96,13 @@ struct PandocClientTests: TestCase {
|
||||
} run: {
|
||||
@Dependency(\.pandocClient) var pandocClient
|
||||
|
||||
let output = try await pandocClient.run.generatePdf(Self.sharedRunOptions, pdfEngine: pdfEngine)
|
||||
let output = try await pandocClient.run.generatePdf(
|
||||
Self.sharedRunOptions, pdfEngine: pdfEngine)
|
||||
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).pdf")
|
||||
|
||||
} assert: { output in
|
||||
let expected = ["pandoc"]
|
||||
let expected =
|
||||
["pandoc"]
|
||||
+ Self.expectedIncludeInHeaders
|
||||
+ ["--pdf-engine=\(pdfEngine ?? "xelatex")"]
|
||||
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).pdf"]
|
||||
@@ -147,10 +151,18 @@ struct TestPdfEngine: Sendable {
|
||||
static let testCases: [Self] = [
|
||||
.init(fileType: .html, expectedEngine: nil, configuration: .init(), defaults: .default),
|
||||
.init(fileType: .latex, expectedEngine: nil, configuration: .init(), defaults: .default),
|
||||
.init(fileType: .pdf(engine: "lualatex"), expectedEngine: "lualatex", configuration: .init(), defaults: .default),
|
||||
.init(fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(), defaults: .default),
|
||||
.init(fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(), defaults: .init()),
|
||||
.init(fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(generate: .default), defaults: .init())
|
||||
.init(
|
||||
fileType: .pdf(engine: "lualatex"), expectedEngine: "lualatex", configuration: .init(),
|
||||
defaults: .default),
|
||||
.init(
|
||||
fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(),
|
||||
defaults: .default),
|
||||
.init(
|
||||
fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(),
|
||||
defaults: .init()),
|
||||
.init(
|
||||
fileType: .pdf(engine: nil), expectedEngine: "xelatex",
|
||||
configuration: .init(generate: .default), defaults: .init()),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -174,19 +186,23 @@ struct TestParseFiles: Sendable {
|
||||
}
|
||||
|
||||
var parsedFiles: [String] {
|
||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
||||
projectDirectory: nil,
|
||||
quiet: true,
|
||||
shouldBuild: false
|
||||
)
|
||||
let runOptions =
|
||||
self.runOptions
|
||||
?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
||||
projectDirectory: nil,
|
||||
quiet: true,
|
||||
shouldBuild: false
|
||||
)
|
||||
|
||||
return runOptions.parseFiles(configuration.generate, defaults)
|
||||
}
|
||||
|
||||
static let testCases: [Self] = [
|
||||
.init(expectedFiles: ["Report.md", "Definitions.md"]),
|
||||
.init(expectedFiles: ["Report.md", "Definitions.md"], configuration: .init(generate: .default), defaults: .init()),
|
||||
.init(
|
||||
expectedFiles: ["Report.md", "Definitions.md"], configuration: .init(generate: .default),
|
||||
defaults: .init()),
|
||||
.init(expectedFiles: [], defaults: .init()),
|
||||
.init(
|
||||
expectedFiles: ["custom.md"],
|
||||
@@ -199,7 +215,7 @@ struct TestParseFiles: Sendable {
|
||||
quiet: true,
|
||||
shouldBuild: false
|
||||
)
|
||||
)
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -223,16 +239,20 @@ struct TestParseIncludeInHeaderFiles: Sendable {
|
||||
}
|
||||
|
||||
var parsedFiles: [String] {
|
||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||
)
|
||||
let runOptions =
|
||||
self.runOptions
|
||||
?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||
)
|
||||
|
||||
return runOptions.parseIncludeInHeader(configuration.generate, defaults)
|
||||
}
|
||||
|
||||
static let testCases: [Self] = [
|
||||
.init(expectedHeaderFiles: ["head.tex", "footer.tex"]),
|
||||
.init(expectedHeaderFiles: ["head.tex", "footer.tex"], configuration: .init(generate: .default), defaults: .init()),
|
||||
.init(
|
||||
expectedHeaderFiles: ["head.tex", "footer.tex"], configuration: .init(generate: .default),
|
||||
defaults: .init()),
|
||||
.init(expectedHeaderFiles: [], defaults: .init()),
|
||||
.init(
|
||||
expectedHeaderFiles: ["custom.tex"],
|
||||
@@ -242,7 +262,7 @@ struct TestParseIncludeInHeaderFiles: Sendable {
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
||||
includeInHeader: ["custom.tex"]
|
||||
)
|
||||
)
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -266,9 +286,11 @@ struct TestParseOutputFileName: Sendable {
|
||||
}
|
||||
|
||||
var parsedFileName: String {
|
||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||
)
|
||||
let runOptions =
|
||||
self.runOptions
|
||||
?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||
)
|
||||
|
||||
return runOptions.parseOutputFileName(configuration.generate, defaults)
|
||||
}
|
||||
@@ -285,7 +307,7 @@ struct TestParseOutputFileName: Sendable {
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
||||
outputFileName: "custom"
|
||||
)
|
||||
)
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -309,9 +331,11 @@ struct TestParseBuildDirectory: Sendable {
|
||||
}
|
||||
|
||||
var parsedBuildDirectory: String {
|
||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||
)
|
||||
let runOptions =
|
||||
self.runOptions
|
||||
?? PandocClient.RunOptions(
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||
)
|
||||
|
||||
return runOptions.parseBuildDirectory(configuration.generate, defaults)
|
||||
}
|
||||
@@ -328,6 +352,6 @@ struct TestParseBuildDirectory: Sendable {
|
||||
buildDirectory: "custom",
|
||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||
)
|
||||
)
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user