Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f9ecc5ce6f
|
@@ -4,10 +4,10 @@ import DependenciesMacros
|
|||||||
import Foundation
|
import Foundation
|
||||||
import ShellClient
|
import ShellClient
|
||||||
|
|
||||||
public extension DependencyValues {
|
extension DependencyValues {
|
||||||
|
|
||||||
/// Runs shell commands.
|
/// Runs shell commands.
|
||||||
var commandClient: CommandClient {
|
public var commandClient: CommandClient {
|
||||||
get { self[CommandClient.self] }
|
get { self[CommandClient.self] }
|
||||||
set { self[CommandClient.self] = newValue }
|
set { self[CommandClient.self] = newValue }
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,8 @@ public struct CommandClient: Sendable {
|
|||||||
in workingDirectory: String? = nil,
|
in workingDirectory: String? = nil,
|
||||||
_ arguments: [String]
|
_ arguments: [String]
|
||||||
) async throws {
|
) async throws {
|
||||||
try await runCommand(.init(
|
try await runCommand(
|
||||||
|
.init(
|
||||||
arguments: arguments,
|
arguments: arguments,
|
||||||
quiet: quiet,
|
quiet: quiet,
|
||||||
shell: shell,
|
shell: shell,
|
||||||
@@ -161,14 +162,16 @@ extension CommandClient: DependencyKey {
|
|||||||
.init { options in
|
.init { options in
|
||||||
@Dependency(\.asyncShellClient) var shellClient
|
@Dependency(\.asyncShellClient) var shellClient
|
||||||
if !options.quiet {
|
if !options.quiet {
|
||||||
try await shellClient.foreground(.init(
|
try await shellClient.foreground(
|
||||||
|
.init(
|
||||||
shell: .init(options.shell),
|
shell: .init(options.shell),
|
||||||
environment: environment,
|
environment: environment,
|
||||||
in: options.workingDirectory,
|
in: options.workingDirectory,
|
||||||
options.arguments
|
options.arguments
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
try await shellClient.background(.init(
|
try await shellClient.background(
|
||||||
|
.init(
|
||||||
shell: .init(options.shell),
|
shell: .init(options.shell),
|
||||||
environment: environment,
|
environment: environment,
|
||||||
in: options.workingDirectory,
|
in: options.workingDirectory,
|
||||||
@@ -184,12 +187,12 @@ extension CommandClient: DependencyKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@_spi(Internal)
|
@_spi(Internal)
|
||||||
public extension CommandClient {
|
extension CommandClient {
|
||||||
|
|
||||||
/// Create a command client that can capture the arguments / options.
|
/// Create a command client that can capture the arguments / options.
|
||||||
///
|
///
|
||||||
/// This is used for testing.
|
/// This is used for testing.
|
||||||
static func capturing(_ client: CapturingClient) -> Self {
|
public static func capturing(_ client: CapturingClient) -> Self {
|
||||||
.init { options in
|
.init { options in
|
||||||
await client.set(options)
|
await client.set(options)
|
||||||
}
|
}
|
||||||
@@ -198,7 +201,7 @@ public extension CommandClient {
|
|||||||
/// Captures the arguments / options passed into the command client's run commands.
|
/// Captures the arguments / options passed into the command client's run commands.
|
||||||
///
|
///
|
||||||
@dynamicMemberLookup
|
@dynamicMemberLookup
|
||||||
actor CapturingClient: Sendable {
|
public actor CapturingClient: Sendable {
|
||||||
public private(set) var options: RunCommandOptions?
|
public private(set) var options: RunCommandOptions?
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
|
|||||||
@@ -6,15 +6,19 @@ import PlaybookClient
|
|||||||
|
|
||||||
extension PandocClient.RunOptions {
|
extension PandocClient.RunOptions {
|
||||||
|
|
||||||
|
/// Runs a pandoc conversion on the project generating the given file type.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - fileType: The file type to convert to.
|
||||||
|
/// - environment: The environment variables.
|
||||||
|
///
|
||||||
|
/// - Returns: File path to the converted output file.
|
||||||
func run(
|
func run(
|
||||||
_ fileType: PandocClient.FileType,
|
_ fileType: PandocClient.FileType,
|
||||||
_ environment: [String: String]
|
_ environment: [String: String]
|
||||||
) async throws -> String {
|
) async throws -> String {
|
||||||
@Dependency(\.commandClient) var commandClient
|
|
||||||
@Dependency(\.logger) var logger
|
@Dependency(\.logger) var logger
|
||||||
@Dependency(\.playbookClient) var playbookClient
|
|
||||||
|
|
||||||
return try await commandClient.run(logging: loggingOptions, quiet: quiet, shell: shell) {
|
|
||||||
let ensuredOptions = try await self.ensuredOptions(fileType)
|
let ensuredOptions = try await self.ensuredOptions(fileType)
|
||||||
|
|
||||||
let projectDirectory = self.projectDirectory ?? environment["PWD"]
|
let projectDirectory = self.projectDirectory ?? environment["PWD"]
|
||||||
@@ -23,9 +27,51 @@ extension PandocClient.RunOptions {
|
|||||||
throw ProjectDirectoryNotSpecified()
|
throw ProjectDirectoryNotSpecified()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try await buildProject(projectDirectory, ensuredOptions)
|
||||||
|
|
||||||
|
let outputDirectory = self.outputDirectory ?? projectDirectory
|
||||||
|
let outputPath = "\(outputDirectory)/\(ensuredOptions.ensuredFilename)"
|
||||||
|
|
||||||
|
let arguments = ensuredOptions.makeArguments(
|
||||||
|
outputPath: outputPath,
|
||||||
|
projectDirectory: projectDirectory
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.debug("Pandoc arguments: \(arguments)")
|
||||||
|
return try await runCommand(arguments, outputPath)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Runs a shell command with the given arguments, returning the passed in output path
|
||||||
|
/// so the command can be chained, if needed.
|
||||||
|
///
|
||||||
|
@discardableResult
|
||||||
|
func runCommand(
|
||||||
|
_ arguments: [String],
|
||||||
|
_ outputPath: String
|
||||||
|
) async throws -> String {
|
||||||
|
@Dependency(\.commandClient) var commandClient
|
||||||
|
@Dependency(\.logger) var logger
|
||||||
|
logger.debug("Running shell command with arguments: \(arguments)")
|
||||||
|
return try await commandClient.run(logging: loggingOptions, quiet: quiet, shell: shell) {
|
||||||
|
(arguments, outputPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build the project if necessary, before running the shell command that builds the final
|
||||||
|
/// output file(s).
|
||||||
|
///
|
||||||
|
func buildProject(
|
||||||
|
_ projectDirectory: String,
|
||||||
|
_ ensuredOptions: EnsuredPandocOptions
|
||||||
|
) async throws {
|
||||||
|
@Dependency(\.logger) var logger
|
||||||
|
@Dependency(\.playbookClient) var playbookClient
|
||||||
|
|
||||||
if shouldBuildProject {
|
if shouldBuildProject {
|
||||||
logger.debug("Building project...")
|
logger.debug("Building project...")
|
||||||
try await playbookClient.run.buildProject(.init(
|
try await playbookClient.run.buildProject(
|
||||||
|
.init(
|
||||||
projectDirectory: projectDirectory,
|
projectDirectory: projectDirectory,
|
||||||
shared: .init(
|
shared: .init(
|
||||||
extraOptions: nil,
|
extraOptions: nil,
|
||||||
@@ -34,23 +80,28 @@ extension PandocClient.RunOptions {
|
|||||||
quiet: quiet,
|
quiet: quiet,
|
||||||
shell: shell
|
shell: shell
|
||||||
)
|
)
|
||||||
))
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let outputDirectory = self.outputDirectory ?? projectDirectory
|
// Build latex file pre-html, so that we can properly convert the latex document
|
||||||
let outputPath = "\(outputDirectory)/\(ensuredOptions.ensuredExtensionFileName)"
|
// into an html document.
|
||||||
|
if ensuredOptions.outputFileType == .html {
|
||||||
let arguments = ensuredOptions.makeArguments(
|
logger.debug("Building latex, pre-html conversion...")
|
||||||
|
let outputPath = "\(ensuredOptions.buildDirectory)/\(EnsuredPandocOptions.latexFilename)"
|
||||||
|
let arguments = ensuredOptions.preHtmlLatexOptions.makeArguments(
|
||||||
outputPath: outputPath,
|
outputPath: outputPath,
|
||||||
projectDirectory: projectDirectory
|
projectDirectory: projectDirectory
|
||||||
)
|
)
|
||||||
|
try await runCommand(arguments, outputPath)
|
||||||
logger.debug("Pandoc arguments: \(arguments)")
|
|
||||||
|
|
||||||
return (arguments, outputPath)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generates the ensured/parsed options for a pandoc conversion.
|
||||||
|
///
|
||||||
|
/// - Parameter fileType: The file type we're converting to.
|
||||||
|
///
|
||||||
|
/// - Returns: The ensured options.
|
||||||
func ensuredOptions(
|
func ensuredOptions(
|
||||||
_ fileType: PandocClient.FileType
|
_ fileType: PandocClient.FileType
|
||||||
) async throws -> EnsuredPandocOptions {
|
) async throws -> EnsuredPandocOptions {
|
||||||
@@ -69,6 +120,7 @@ extension PandocClient.RunOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension PandocClient.FileType {
|
extension PandocClient.FileType {
|
||||||
|
/// Represents the appropriate file extension for a file type.
|
||||||
var fileExtension: String {
|
var fileExtension: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .html: return "html"
|
case .html: return "html"
|
||||||
@@ -78,8 +130,14 @@ extension PandocClient.FileType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents pandoc options that get parsed based on the given run options, configuration, etc.
|
||||||
|
///
|
||||||
|
/// This set's potentially optional values into real values that are required for pandoc to run
|
||||||
|
/// properly and convert files for the given file type conversion.
|
||||||
@_spi(Internal)
|
@_spi(Internal)
|
||||||
public struct EnsuredPandocOptions: Equatable, Sendable {
|
public struct EnsuredPandocOptions: Equatable, Sendable {
|
||||||
|
public static let latexFilename = "Report.tex"
|
||||||
|
|
||||||
public let buildDirectory: String
|
public let buildDirectory: String
|
||||||
public let extraOptions: [String]?
|
public let extraOptions: [String]?
|
||||||
public let files: [String]
|
public let files: [String]
|
||||||
@@ -88,7 +146,9 @@ public struct EnsuredPandocOptions: Equatable, Sendable {
|
|||||||
public let outputFileType: PandocClient.FileType
|
public let outputFileType: PandocClient.FileType
|
||||||
public let pdfEngine: String?
|
public let pdfEngine: String?
|
||||||
|
|
||||||
public var ensuredExtensionFileName: String {
|
/// Ensures the output filename includes the file extension, so that pandoc
|
||||||
|
/// can properly convert the files.
|
||||||
|
public var ensuredFilename: String {
|
||||||
let extensionString = ".\(outputFileType.fileExtension)"
|
let extensionString = ".\(outputFileType.fileExtension)"
|
||||||
|
|
||||||
if !outputFileName.hasSuffix(extensionString) {
|
if !outputFileName.hasSuffix(extensionString) {
|
||||||
@@ -97,15 +157,34 @@ public struct EnsuredPandocOptions: Equatable, Sendable {
|
|||||||
return outputFileName
|
return outputFileName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generates the options required for building the latex file that is needed
|
||||||
|
/// to convert the project to an html output file.
|
||||||
|
var preHtmlLatexOptions: Self {
|
||||||
|
.init(
|
||||||
|
buildDirectory: buildDirectory,
|
||||||
|
extraOptions: extraOptions,
|
||||||
|
files: files,
|
||||||
|
includeInHeader: includeInHeader,
|
||||||
|
outputFileName: Self.latexFilename,
|
||||||
|
outputFileType: .latex,
|
||||||
|
pdfEngine: nil
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generate arguments for the pandoc shell command based on the parsed options
|
||||||
|
/// for a given conversion.
|
||||||
|
///
|
||||||
func makeArguments(
|
func makeArguments(
|
||||||
outputPath: String,
|
outputPath: String,
|
||||||
projectDirectory: String
|
projectDirectory: String
|
||||||
) -> [String] {
|
) -> [String] {
|
||||||
var arguments = [PandocClient.Constants.pandocCommand]
|
var arguments = [PandocClient.Constants.pandocCommand]
|
||||||
|
|
||||||
|
if outputFileType != .html {
|
||||||
arguments += includeInHeader.map {
|
arguments += includeInHeader.map {
|
||||||
"--include-in-header=\(projectDirectory)/\(buildDirectory)/\($0)"
|
"--include-in-header=\(projectDirectory)/\(buildDirectory)/\($0)"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let pdfEngine {
|
if let pdfEngine {
|
||||||
arguments.append("--pdf-engine=\(pdfEngine)")
|
arguments.append("--pdf-engine=\(pdfEngine)")
|
||||||
@@ -117,9 +196,13 @@ public struct EnsuredPandocOptions: Equatable, Sendable {
|
|||||||
arguments.append(contentsOf: extraOptions)
|
arguments.append(contentsOf: extraOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if outputFileType != .html {
|
||||||
arguments += files.map {
|
arguments += files.map {
|
||||||
"\(projectDirectory)/\(buildDirectory)/\($0)"
|
"\(projectDirectory)/\(buildDirectory)/\($0)"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
arguments.append("\(projectDirectory)/\(buildDirectory)/\(Self.latexFilename)")
|
||||||
|
}
|
||||||
|
|
||||||
return arguments
|
return arguments
|
||||||
}
|
}
|
||||||
@@ -145,15 +228,15 @@ public func ensurePandocOptions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@_spi(Internal)
|
@_spi(Internal)
|
||||||
public extension PandocClient.FileType {
|
extension PandocClient.FileType {
|
||||||
func parsePdfEngine(
|
public func parsePdfEngine(
|
||||||
_ configuration: Configuration.Generate?,
|
_ configuration: Configuration.Generate?,
|
||||||
_ defaults: Configuration.Generate
|
_ defaults: Configuration.Generate
|
||||||
) -> String? {
|
) -> String? {
|
||||||
switch self {
|
switch self {
|
||||||
case .html, .latex:
|
case .html, .latex:
|
||||||
return nil
|
return nil
|
||||||
case let .pdf(engine: engine):
|
case .pdf(let engine):
|
||||||
if let engine {
|
if let engine {
|
||||||
return engine
|
return engine
|
||||||
} else if let engine = configuration?.pdfEngine {
|
} else if let engine = configuration?.pdfEngine {
|
||||||
@@ -168,8 +251,8 @@ public extension PandocClient.FileType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@_spi(Internal)
|
@_spi(Internal)
|
||||||
public extension PandocClient.RunOptions {
|
extension PandocClient.RunOptions {
|
||||||
func parseFiles(
|
public func parseFiles(
|
||||||
_ configuration: Configuration.Generate?,
|
_ configuration: Configuration.Generate?,
|
||||||
_ defaults: Configuration.Generate
|
_ defaults: Configuration.Generate
|
||||||
) -> [String] {
|
) -> [String] {
|
||||||
@@ -187,7 +270,7 @@ public extension PandocClient.RunOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseIncludeInHeader(
|
public func parseIncludeInHeader(
|
||||||
_ configuration: Configuration.Generate?,
|
_ configuration: Configuration.Generate?,
|
||||||
_ defaults: Configuration.Generate
|
_ defaults: Configuration.Generate
|
||||||
) -> [String] {
|
) -> [String] {
|
||||||
@@ -205,7 +288,7 @@ public extension PandocClient.RunOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseOutputFileName(
|
public func parseOutputFileName(
|
||||||
_ configuration: Configuration.Generate?,
|
_ configuration: Configuration.Generate?,
|
||||||
_ defaults: Configuration.Generate
|
_ defaults: Configuration.Generate
|
||||||
) -> String {
|
) -> String {
|
||||||
@@ -223,7 +306,7 @@ public extension PandocClient.RunOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseBuildDirectory(
|
public func parseBuildDirectory(
|
||||||
_ configuration: Configuration.Generate?,
|
_ configuration: Configuration.Generate?,
|
||||||
_ defaults: Configuration.Generate
|
_ defaults: Configuration.Generate
|
||||||
) -> String {
|
) -> String {
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import Dependencies
|
|||||||
import DependenciesMacros
|
import DependenciesMacros
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public extension DependencyValues {
|
extension DependencyValues {
|
||||||
|
|
||||||
/// Represents interactions with the `pandoc` command line application.
|
/// Represents interactions with the `pandoc` command line application.
|
||||||
///
|
///
|
||||||
/// The `pandoc` command line application is used to generate the final output
|
/// The `pandoc` command line application is used to generate the final output
|
||||||
/// documents from a home performance assessment project.
|
/// documents from a home performance assessment project.
|
||||||
///
|
///
|
||||||
var pandocClient: PandocClient {
|
public var pandocClient: PandocClient {
|
||||||
get { self[PandocClient.self] }
|
get { self[PandocClient.self] }
|
||||||
set { self[PandocClient.self] = newValue }
|
set { self[PandocClient.self] = newValue }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
@_spi(Internal) import ConfigurationClient
|
@_spi(Internal) import ConfigurationClient
|
||||||
@_spi(Internal) import PandocClient
|
@_spi(Internal) import PandocClient
|
||||||
import PlaybookClient
|
import PlaybookClient
|
||||||
import Testing
|
|
||||||
import TestSupport
|
import TestSupport
|
||||||
|
import Testing
|
||||||
|
|
||||||
@Suite("PandocClientTests")
|
@Suite("PandocClientTests")
|
||||||
struct PandocClientTests: TestCase {
|
struct PandocClientTests: TestCase {
|
||||||
@@ -13,12 +13,12 @@ struct PandocClientTests: TestCase {
|
|||||||
|
|
||||||
static let expectedIncludeInHeaders = [
|
static let expectedIncludeInHeaders = [
|
||||||
"--include-in-header=/project/.build/head.tex",
|
"--include-in-header=/project/.build/head.tex",
|
||||||
"--include-in-header=/project/.build/footer.tex"
|
"--include-in-header=/project/.build/footer.tex",
|
||||||
]
|
]
|
||||||
|
|
||||||
static let expectedFiles = [
|
static let expectedFiles = [
|
||||||
"/project/.build/Report.md",
|
"/project/.build/Report.md",
|
||||||
"/project/.build/Definitions.md"
|
"/project/.build/Definitions.md",
|
||||||
]
|
]
|
||||||
|
|
||||||
static var sharedRunOptions: PandocClient.RunOptions {
|
static var sharedRunOptions: PandocClient.RunOptions {
|
||||||
@@ -49,7 +49,8 @@ struct PandocClientTests: TestCase {
|
|||||||
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).tex")
|
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).tex")
|
||||||
|
|
||||||
} assert: { output in
|
} assert: { output in
|
||||||
let expected = ["pandoc"]
|
let expected =
|
||||||
|
["pandoc"]
|
||||||
+ Self.expectedIncludeInHeaders
|
+ Self.expectedIncludeInHeaders
|
||||||
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).tex"]
|
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).tex"]
|
||||||
+ Self.expectedFiles
|
+ Self.expectedFiles
|
||||||
@@ -71,10 +72,11 @@ struct PandocClientTests: TestCase {
|
|||||||
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).html")
|
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).html")
|
||||||
|
|
||||||
} assert: { output in
|
} assert: { output in
|
||||||
let expected = ["pandoc"]
|
let expected = [
|
||||||
+ Self.expectedIncludeInHeaders
|
"pandoc",
|
||||||
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).html"]
|
"--output=\(Self.outputDirectory)/\(Self.defaultFileName).html",
|
||||||
+ Self.expectedFiles
|
"\(Self.projectDirectory)/.build/Report.tex",
|
||||||
|
]
|
||||||
|
|
||||||
#expect(output.arguments == expected)
|
#expect(output.arguments == expected)
|
||||||
}
|
}
|
||||||
@@ -83,7 +85,7 @@ struct PandocClientTests: TestCase {
|
|||||||
@Test(
|
@Test(
|
||||||
arguments: [
|
arguments: [
|
||||||
nil,
|
nil,
|
||||||
"lualatex"
|
"lualatex",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
func generatePdf(pdfEngine: String?) async throws {
|
func generatePdf(pdfEngine: String?) async throws {
|
||||||
@@ -94,11 +96,13 @@ struct PandocClientTests: TestCase {
|
|||||||
} run: {
|
} run: {
|
||||||
@Dependency(\.pandocClient) var pandocClient
|
@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")
|
#expect(output == "\(Self.outputDirectory)/\(Self.defaultFileName).pdf")
|
||||||
|
|
||||||
} assert: { output in
|
} assert: { output in
|
||||||
let expected = ["pandoc"]
|
let expected =
|
||||||
|
["pandoc"]
|
||||||
+ Self.expectedIncludeInHeaders
|
+ Self.expectedIncludeInHeaders
|
||||||
+ ["--pdf-engine=\(pdfEngine ?? "xelatex")"]
|
+ ["--pdf-engine=\(pdfEngine ?? "xelatex")"]
|
||||||
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).pdf"]
|
+ ["--output=\(Self.outputDirectory)/\(Self.defaultFileName).pdf"]
|
||||||
@@ -147,10 +151,18 @@ struct TestPdfEngine: Sendable {
|
|||||||
static let testCases: [Self] = [
|
static let testCases: [Self] = [
|
||||||
.init(fileType: .html, expectedEngine: nil, configuration: .init(), defaults: .default),
|
.init(fileType: .html, expectedEngine: nil, configuration: .init(), defaults: .default),
|
||||||
.init(fileType: .latex, 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(
|
||||||
.init(fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(), defaults: .default),
|
fileType: .pdf(engine: "lualatex"), expectedEngine: "lualatex", configuration: .init(),
|
||||||
.init(fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(), defaults: .init()),
|
defaults: .default),
|
||||||
.init(fileType: .pdf(engine: nil), expectedEngine: "xelatex", configuration: .init(generate: .default), defaults: .init())
|
.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,7 +186,9 @@ struct TestParseFiles: Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parsedFiles: [String] {
|
var parsedFiles: [String] {
|
||||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
let runOptions =
|
||||||
|
self.runOptions
|
||||||
|
?? PandocClient.RunOptions(
|
||||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
||||||
projectDirectory: nil,
|
projectDirectory: nil,
|
||||||
quiet: true,
|
quiet: true,
|
||||||
@@ -186,7 +200,9 @@ struct TestParseFiles: Sendable {
|
|||||||
|
|
||||||
static let testCases: [Self] = [
|
static let testCases: [Self] = [
|
||||||
.init(expectedFiles: ["Report.md", "Definitions.md"]),
|
.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: [], defaults: .init()),
|
||||||
.init(
|
.init(
|
||||||
expectedFiles: ["custom.md"],
|
expectedFiles: ["custom.md"],
|
||||||
@@ -199,7 +215,7 @@ struct TestParseFiles: Sendable {
|
|||||||
quiet: true,
|
quiet: true,
|
||||||
shouldBuild: false
|
shouldBuild: false
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +239,9 @@ struct TestParseIncludeInHeaderFiles: Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parsedFiles: [String] {
|
var parsedFiles: [String] {
|
||||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
let runOptions =
|
||||||
|
self.runOptions
|
||||||
|
?? PandocClient.RunOptions(
|
||||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -232,7 +250,9 @@ struct TestParseIncludeInHeaderFiles: Sendable {
|
|||||||
|
|
||||||
static let testCases: [Self] = [
|
static let testCases: [Self] = [
|
||||||
.init(expectedHeaderFiles: ["head.tex", "footer.tex"]),
|
.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: [], defaults: .init()),
|
||||||
.init(
|
.init(
|
||||||
expectedHeaderFiles: ["custom.tex"],
|
expectedHeaderFiles: ["custom.tex"],
|
||||||
@@ -242,7 +262,7 @@ struct TestParseIncludeInHeaderFiles: Sendable {
|
|||||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
||||||
includeInHeader: ["custom.tex"]
|
includeInHeader: ["custom.tex"]
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +286,9 @@ struct TestParseOutputFileName: Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parsedFileName: String {
|
var parsedFileName: String {
|
||||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
let runOptions =
|
||||||
|
self.runOptions
|
||||||
|
?? PandocClient.RunOptions(
|
||||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -285,7 +307,7 @@ struct TestParseOutputFileName: Sendable {
|
|||||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug),
|
||||||
outputFileName: "custom"
|
outputFileName: "custom"
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +331,9 @@ struct TestParseBuildDirectory: Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parsedBuildDirectory: String {
|
var parsedBuildDirectory: String {
|
||||||
let runOptions = self.runOptions ?? PandocClient.RunOptions(
|
let runOptions =
|
||||||
|
self.runOptions
|
||||||
|
?? PandocClient.RunOptions(
|
||||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -328,6 +352,6 @@ struct TestParseBuildDirectory: Sendable {
|
|||||||
buildDirectory: "custom",
|
buildDirectory: "custom",
|
||||||
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
loggingOptions: .init(commandName: "parseFiles", logLevel: .debug)
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user