diff --git a/.circleci/config.yml b/.circleci/config.yml index 918d861b..aa03700f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: diff --git a/Tests/XcodeGenKitTests/ProjectFixtureTests.swift b/Tests/XcodeGenKitTests/ProjectFixtureTests.swift index b66e50b3..028c7173 100644 --- a/Tests/XcodeGenKitTests/ProjectFixtureTests.swift +++ b/Tests/XcodeGenKitTests/ProjectFixtureTests.swift @@ -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 } diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 7e5e624d..df246301 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -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") { diff --git a/diff-fixtures.sh b/diff-fixtures.sh new file mode 100755 index 00000000..183a9bdd --- /dev/null +++ b/diff-fixtures.sh @@ -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