compass
compass copied to clipboard
feat(export-to-language) add Swift support as a target language for export SWIFT-1458
Description
This adds a Swift target for the language transpilation, enabling export for find and aggregate pipelines.
Checklist
- [x] New tests and/or benchmarks are included
- [ ] Documentation is changed or added
Motivation and Context
- [ ] Bugfix
- [x] New feature
- [ ] Dependency update
- [ ] Misc
Types of changes
- [ ] Backport Needed
- [ ] Patch (non-breaking change which fixes an issue)
- [x] Minor (non-breaking change which adds functionality)
- [ ] Major (fix or feature that would cause existing functionality to change)
LGTM from the Swift perspective excluding the conversation above about type annotations with the open question for DevTools
@mcasimir and team, this should be ready for your review whenever you get a chance
Looks awesome! There are some conflicts introduced by another language support that was added recently, do you mind resolving?
Seems like the test failures are not just flakes, but relevant to the changes (a few expected outcomes are missing in the tests it seems?)
[2022/05/03 21:43:21.008] bson-transpilers: 1) native
[2022/05/03 21:43:21.008] bson-transpilers: Tuple
[2022/05/03 21:43:21.008] bson-transpilers: python: ('1', { 'settings': 'http2' }) => swift:
[2022/05/03 21:43:21.008] bson-transpilers: AssertionError: expected '[\n "1",\n [\n "settings…' to equal '[\n "1",\n [\n "settings…'
[2022/05/03 21:43:21.008] bson-transpilers: + expected - actual
[2022/05/03 21:43:21.008] bson-transpilers: [
[2022/05/03 21:43:21.008] bson-transpilers: "1",
[2022/05/03 21:43:21.008] bson-transpilers: [
[2022/05/03 21:43:21.008] bson-transpilers: "settings": "http2"
[2022/05/03 21:43:21.008] bson-transpilers: - ]
[2022/05/03 21:43:21.008] bson-transpilers: -]
[2022/05/03 21:43:21.008] bson-transpilers: + ]
[2022/05/03 21:43:21.008] bson-transpilers:
[2022/05/03 21:43:21.008] bson-transpilers: at Context.eval (eval at constructJavascriptFunction (/data/mci/da21ab3dcd1e5d23d216d9cf3ffc8a0c/src/node_modules/js-yaml/lib/js-yaml/type/js/function.js:71:12), <anonymous>:7:14)
[2022/05/03 21:43:21.008] bson-transpilers: at processImmediate (internal/timers.js:464:21)
[2022/05/03 21:43:21.009] bson-transpilers: 2) native
[2022/05/03 21:43:21.009] bson-transpilers: Tuple
[2022/05/03 21:43:21.009] bson-transpilers: python: ('1', ['2', '3']) => swift:
[2022/05/03 21:43:21.009] bson-transpilers: AssertionError: expected '[\n "1",\n [\n "2",\n …' to equal ''
[2022/05/03 21:43:21.009] bson-transpilers: + expected - actual
[2022/05/03 21:43:21.009] bson-transpilers: -[
[2022/05/03 21:43:21.009] bson-transpilers: - "1",
[2022/05/03 21:43:21.009] bson-transpilers: - [
[2022/05/03 21:43:21.009] bson-transpilers: - "2",
[2022/05/03 21:43:21.009] bson-transpilers: - "3"
[2022/05/03 21:43:21.009] bson-transpilers: - ]
[2022/05/03 21:43:21.009] bson-transpilers: -]
[2022/05/03 21:43:21.009] bson-transpilers:
[2022/05/03 21:43:21.009] bson-transpilers: at Context.eval (eval at constructJavascriptFunction (/data/mci/da21ab3dcd1e5d23d216d9cf3ffc8a0c/src/node_modules/js-yaml/lib/js-yaml/type/js/function.js:71:12), <anonymous>:7:14)
[2022/05/03 21:43:21.009] bson-transpilers: at processImmediate (internal/timers.js:464:21)
[2022/05/03 21:43:21.009] bson-transpilers: 3) native
[2022/05/03 21:43:21.009] bson-transpilers: Tuple
[2022/05/03 21:43:21.009] bson-transpilers: python: ['1', ('2', '3')] => swift:
[2022/05/03 21:43:21.009] bson-transpilers: AssertionError: expected '[\n "1",\n [\n "2",\n …' to equal ''
[2022/05/03 21:43:21.009] bson-transpilers: + expected - actual
[2022/05/03 21:43:21.009] bson-transpilers: -[
[2022/05/03 21:43:21.009] bson-transpilers: - "1",
[2022/05/03 21:43:21.009] bson-transpilers: - [
[2022/05/03 21:43:21.009] bson-transpilers: - "2",
[2022/05/03 21:43:21.009] bson-transpilers: - "3"
[2022/05/03 21:43:21.009] bson-transpilers: - ]
[2022/05/03 21:43:21.009] bson-transpilers: -]
Oh whoops, looks like some of the test assertions got messed up during the merge. Should be fixed now and ready for review.
I'm going to close this PR for the time being as it has been inactive for a while by now. We can always re-open it if we want to get some progress