Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/librarian/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ func defaultOutput(language string, name, api, defaultOut string) string {
return python.DefaultOutput(name, defaultOut)
case config.LanguageRust:
return rust.DefaultOutput(api, defaultOut)
case config.LanguageSwift:
return swift.DefaultOutput(api, defaultOut)
default:
return defaultOut
}
Expand Down
24 changes: 24 additions & 0 deletions internal/librarian/swift/default_output.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package swift

import "path/filepath"

// DefaultOutput derives an output path from a library name and a default
// output directory. Currently, this just assumes each library is a directory
// directly underneath the default output directory.
func DefaultOutput(name, defaultOutput string) string {
return filepath.Join(defaultOutput, name)
}
54 changes: 54 additions & 0 deletions internal/librarian/swift/default_output_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package swift

import "testing"

func TestDefaultOutput(t *testing.T) {
tests := []struct {
name string
libName string
defOut string
want string
}{
{
name: "simple",
libName: "secretmanager",
defOut: "packages",
want: "packages/secretmanager",
},
{
name: "empty default",
libName: "secretmanager",
defOut: "",
want: "secretmanager",
},
{
name: "nested default",
libName: "secretmanager",
defOut: "a/b/c",
want: "a/b/c/secretmanager",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := DefaultOutput(tt.libName, tt.defOut)
if got != tt.want {
t.Errorf("DefaultOutput(%q, %q) = %q; want %q", tt.libName, tt.defOut, got, tt.want)
}
})
}
}
Loading