check fixtures using git diff

This commit is contained in:
Yonas Kolb
2018-09-29 20:48:11 +10:00
parent ab8f43f587
commit d5b72bce4f
4 changed files with 34 additions and 30 deletions
+13 -7
View File
@@ -12,11 +12,14 @@ jobs:
name: Test
command: swift test 2>&1 | xcpretty
- run:
name: Build release
command: make build
name: Check Project Diff
command: ./diff-fixtures.sh
- run:
name: Build Test Project
command: ./build-fixtures.sh
- run:
name: Build release
command: make build
macOS_swift_4.2:
macos:
xcode: "10.0.0"
@@ -25,16 +28,19 @@ jobs:
- run:
name: Build
command: swift build
- run:
name: Test
command: swift test 2>&1 | xcpretty
# disabled till UUID's are stable
# - run:
# name: Test
# command: swift test 2>&1 | xcpretty
- run:
name: Build release
command: make build
# name: Check Project Diff
# command: ./diff-fixtures.sh
- run:
name: Build Test Project
command: ./build-fixtures.sh
- run:
name: Build release
command: make build
workflows:
version: 2
workflow:
@@ -62,21 +62,7 @@ fileprivate func generateXcodeProject(specPath: Path, projectPath: Path, file: S
let project = try Project(path: specPath)
let generator = ProjectGenerator(project: project)
let xcodeProject = try generator.generateXcodeProject()
let oldProject = try XcodeProj(path: projectPath)
let pbxProjPath = projectPath + XcodeProj.pbxprojPath(projectPath)
let oldProjectString: String = try pbxProjPath.read()
try xcodeProject.write(path: projectPath, override: true)
let newProjectString: String = try pbxProjPath.read()
let newProject = try XcodeProj(path: projectPath)
let stringDiff = newProjectString != oldProjectString
if newProject != oldProject || stringDiff {
var message = "\(projectPath.string) has changed. If change is legitimate commit the change and run test again"
if stringDiff {
message += ":\n\n\(pbxProjPath):\n\(prettyFirstDifferenceBetweenStrings(oldProjectString, newProjectString))"
}
throw failure(message, file: file, line: line)
}
return newProject
return xcodeProject
}
@@ -733,15 +733,14 @@ class ProjectGeneratorTests: XCTestCase {
}
let buildPhases = nativeTarget.buildPhases
let scripts = pbxProject.objects.shellScriptBuildPhases.objectReferences
let script1 = scripts[0]
let script2 = scripts[1]
try expect(scripts.count) == 2
try expect(buildPhases.first) == script1.reference
try expect(buildPhases.last) == script2.reference
let scripts = pbxProject.objects.shellScriptBuildPhases
let script1 = scripts.first { $0.value.shellScript == "script1" }
let script2 = scripts.first { $0.value.shellScript == "script2" }
try expect(script1.object.shellScript) == "script1"
try expect(script2.object.shellScript) == "script2"
try expect(scripts.count) == 2
try expect(buildPhases.first) == script1?.key
try expect(buildPhases.last) == script2?.key
}
$0.it("generates targets with cylical dependencies") {
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
if [[ `git status --porcelain Tests/Fixtures/TestProject` ]]; then
echo ""
echo "⚠️ Generated TestProject has changed."
echo "⚠️ If this is a valid change please run the tests and commit the updated TestProject."
echo ""
git --no-pager diff --color=always Tests/Fixtures/TestProject
exit 1
else
echo "✅ Generated TestProject has not changed."
fi