Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: group generated output files per command & output #598

Merged
merged 3 commits into from
Feb 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ _None_
### Internal Changes

* Refactoring: Reduce globals & rearrange CLI code.
[#586](https://github.com/SwiftGen/SwiftGen/pull/586)
[@AliSoftware](https://github.com/AliSoftware)
[#586](https://github.com/SwiftGen/SwiftGen/pull/586)
* Moved generated test output files into subdirectories per template.
[David Jennes](https://github.com/djbe)
[#598](https://github.com/SwiftGen/SwiftGen/pull/598)

## 6.1.0

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/colors/literals-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension ColorName {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Colors/literals-swift3-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Colors/literals-swift3/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/colors/literals-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension ColorName {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Colors/literals-swift4-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Colors/literals-swift4/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/colors/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ColorName {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Colors/swift3-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Colors/swift3/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/colors/swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ColorName {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Colors/swift4-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Colors/swift4/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/coredata/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extension MainEntity {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/CoreData/swift3-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/CoreData/swift3/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/coredata/swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extension MainEntity {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/CoreData/swift4-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/CoreData/swift4/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/fonts/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum FontFamily {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Fonts/swift3-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Fonts/swift3/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/fonts/swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum FontFamily {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Fonts/swift4-context-defaults.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Fonts/swift4/defaults.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/ib/scenes-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum StoryboardScene {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/scenes-swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/scenes-swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/ib/scenes-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum StoryboardScene {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/scenes-swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/scenes-swift4/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/ib/segues-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum StoryboardSegue {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/ib/segues-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum StoryboardSegue {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/IB-iOS/swift4/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/json/inline-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal enum JSONFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/JSON/inline-swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/JSON/inline-swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/json/inline-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal enum JSONFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/JSON/inline-swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/JSON/inline-swift4/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/json/runtime-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal enum JSONFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/JSON/runtime-swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/JSON/runtime-swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/json/runtime-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal enum JSONFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/JSON/runtime-swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/JSON/runtime-swift4/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/plist/inline-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal enum PlistFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Plist/inline-swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Plist/inline-swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/plist/inline-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal enum PlistFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Plist/inline-swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Plist/inline-swift4/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/plist/runtime-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal enum PlistFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Plist/runtime-swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Plist/runtime-swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/plist/runtime-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal enum PlistFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Plist/runtime-swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Plist/runtime-swift4/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/strings/flat-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum L10n {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Strings/flat-swift3-context-localizable.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Strings/flat-swift3/localizable.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/strings/flat-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum L10n {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Strings/flat-swift4-context-localizable.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Strings/flat-swift4/localizable.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/strings/structured-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum L10n {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Strings/structured-swift3-context-localizable.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Strings/structured-swift3/localizable.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/strings/structured-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum L10n {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/Strings/structured-swift4-context-localizable.swift)
[Full generated code](../../../Tests/Fixtures/Generated/Strings/structured-swift4/localizable.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/xcassets/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum Asset {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/XCAssets/swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/XCAssets/swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/xcassets/swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum Asset {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/XCAssets/swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/XCAssets/swift4/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/yaml/inline-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal enum YAMLFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/YAML/inline-swift3-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/YAML/inline-swift3/all.swift)

## Usage example

Expand Down
2 changes: 1 addition & 1 deletion Documentation/templates/yaml/inline-swift4.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal enum YAMLFiles {
}
```

[Full generated code](../../../Tests/Fixtures/Generated/YAML/inline-swift4-context-all.swift)
[Full generated code](../../../Tests/Fixtures/Generated/YAML/inline-swift4/all.swift)

## Usage example

Expand Down
11 changes: 6 additions & 5 deletions Tests/TemplatesTests/TestsHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class Fixtures {
return string(for: name, subDirectory: "templates/\(sub.rawValue.lowercased())")
}

static func output(for name: String, sub: Directory) -> String {
return string(for: name, subDirectory: "Generated/\(sub.rawValue)")
static func output(template: String, variation: String, sub: Directory) -> String {
return string(for: variation, subDirectory: "Generated/\(sub.rawValue)/\(template)")
}

private static func string(for name: String, subDirectory: String) -> String {
Expand Down Expand Up @@ -182,7 +182,7 @@ extension XCTestCase {
}

for (index, (context: context, suffix: suffix)) in variations.enumerated() {
let outputFile = "\(templateName)-context-\(contextName)\(suffix).swift"
let outputFile = "\(contextName)\(suffix).swift"
if variations.count > 1 { print(" - Variation #\(index)... (expecting: \(outputFile))") }

let result: String
Expand All @@ -194,14 +194,15 @@ extension XCTestCase {

// check if we should generate or not
if ProcessInfo().environment["GENERATE_OUTPUT"] == "YES" {
let target = Path(#file).parent().parent() + "Fixtures/Generated" + outputDir.rawValue + outputFile
let target = Path(#file).parent().parent() + "Fixtures/Generated" + outputDir.rawValue +
templateName + outputFile
do {
try target.write(result)
} catch {
fatalError("Unable to write output file \(target)")
}
} else {
let expected = Fixtures.output(for: outputFile, sub: outputDir)
let expected = Fixtures.output(template: templateName, variation: outputFile, sub: outputDir)
XCTDiffStrings(result, expected, file: file, line: line)
}
}
Expand Down