This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-connect-swift.git
The following commit(s) were added to refs/heads/main by this push:
new d709159 [SPARK-51870] Support `SPARK_GENERATE_GOLDEN_FILES` in
`SQLTests`
d709159 is described below
commit d7091599420bf5c53ddd26e35a9e36e747c80330
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Wed Apr 23 09:31:09 2025 +0900
[SPARK-51870] Support `SPARK_GENERATE_GOLDEN_FILES` in `SQLTests`
### What changes were proposed in this pull request?
This PR aims to support `SPARK_GENERATE_GOLDEN_FILES` in `SQLTests`.
### Why are the changes needed?
To improve `SQLTests`.
### Does this PR introduce _any_ user-facing change?
No, this is a test-related improvement.
### How was this patch tested?
Pass the CIs and manual review.
```
SPARK_GENERATE_GOLDEN_FILES=1 swift test --filter SQLTests
```
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #84 from dongjoon-hyun/SPARK-51870.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
Tests/SparkConnectTests/SQLTests.swift | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/Tests/SparkConnectTests/SQLTests.swift
b/Tests/SparkConnectTests/SQLTests.swift
index 7df5c99..7f7ae8b 100644
--- a/Tests/SparkConnectTests/SQLTests.swift
+++ b/Tests/SparkConnectTests/SQLTests.swift
@@ -26,7 +26,7 @@ import SparkConnect
struct SQLTests {
let fm = FileManager.default
let path = Bundle.module.path(forResource: "queries", ofType: "")!
- let encoder = JSONEncoder()
+ let regenerateGoldenFiles =
ProcessInfo.processInfo.environment["SPARK_GENERATE_GOLDEN_FILES"] == "1"
let regexID = /#\d+L?/
let regexPlanId = /plan_id=\d+/
@@ -79,8 +79,13 @@ struct SQLTests {
let sql = try String(contentsOf: URL(fileURLWithPath:
"\(path)/\(name)"), encoding: .utf8)
let answer = cleanUp(try await spark.sql(sql).collect().map {
$0.toString() }.joined(separator: "\n"))
- let expected = cleanUp(try String(contentsOf: URL(fileURLWithPath:
"\(path)/\(name).answer"), encoding: .utf8))
- #expect(answer == expected.trimmingCharacters(in:
.whitespacesAndNewlines))
+ if (regenerateGoldenFiles) {
+ let path =
"\(FileManager.default.currentDirectoryPath)/Tests/SparkConnectTests/Resources/queries/\(name).answer"
+ fm.createFile(atPath: path, contents: (answer + "\n").data(using:
.utf8)!, attributes: nil)
+ } else {
+ let expected = cleanUp(try String(contentsOf: URL(fileURLWithPath:
"\(path)/\(name).answer"), encoding: .utf8))
+ #expect(answer == expected.trimmingCharacters(in:
.whitespacesAndNewlines))
+ }
}
await spark.stop()
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]