Fix scripts.

This commit is contained in:
Filip Dolník 2016-12-07 20:22:21 +01:00
parent c3e945f8c2
commit 1330e65061
10 changed files with 54 additions and 39 deletions

1
.gitignore vendored
View File

@ -35,3 +35,4 @@ Carthage/Build
.DS_Store
default.profraw
Tests/Generated/*.swift
Generator/*.app

View File

@ -13,6 +13,7 @@ script:
- bash run_tests.sh
- cd ..
- xcodebuild -workspace 'Cuckoo.xcworkspace' -scheme 'Cuckoo' clean test
- pod lib lint
after_script:
- sleep 5

View File

@ -513,13 +513,15 @@
files = (
);
inputPaths = (
"$(SRCROOT)/Tests/Source/TestedProtocol.swift",
"$(SRCROOT)/Tests/Source/TestedClass.swift",
);
name = "Generate mocks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "$BUILD_DIR/$CONFIGURATION/cuckoo_generator.app/Contents/MacOS/cuckoo_generator generate --output \"$PROJECT_DIR/Tests/Generated/GeneratedMocks.swift\" \"$PROJECT_DIR/Tests/Source/TestedClass.swift\" \"$PROJECT_DIR/Tests/Source/TestedProtocol.swift\" \"$PROJECT_DIR/Tests/Source/ClassForStubTesting.swift\"";
shellScript = "OUTPUT=\"$PROJECT_DIR/Tests/Generated/GeneratedMocks.swift\"\nINPUT=\"$PROJECT_DIR/Tests/Source/ClassForStubTesting.swift\"\n\"$BUILD_DIR/$CONFIGURATION/cuckoo_generator.app/Contents/MacOS/cuckoo_generator\" generate --output \"$OUTPUT\" \"$INPUT\"\n#\"$PROJECT_DIR/run\" --clean generate --output \"$OUTPUT\" \"$INPUT\"\n";
};
/* End PBXShellScriptBuildPhase section */

View File

@ -21,7 +21,7 @@
"64ACE19A884E8C30BC53E2E0CE86010ECED70B5A" : "Cuckoo\/Generator\/Dependencies\/FileKit\/",
"FD7DA18210A2C280E9107E37D7344F243FEE5F75" : "Cuckoo\/Generator\/Dependencies\/SourceKitten\/",
"EB2210CFD48672E403BED699D5D7F01B844069CF" : "Cuckoo\/Generator\/Dependencies\/SourceKitten\/Carthage\/Checkouts\/SWXMLHash\/",
"E084C86B03F81D63323C9E7510697EA528A758C7" : "Cuckoo\/Generator\/Dependencies\/SourceKitten\/Carthage\/Checkouts\/Commandant\/Carthage\/Checkouts\/xcconfigs\/",
"E084C86B03F81D63323C9E7510697EA528A758C7" : "Cuckoo\/Generator\/Dependencies\/SourceKitten\/Carthage\/Checkouts\/xcconfigs\/",
"509FD5E949BB67AB92770169324D45AB1917F796" : "Cuckoo\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "Cuckoo",

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
./run_tests.sh "$@"
for file in Build/log/*/*.swift; do
fileName=$(echo "$file" | rev | cut -d"/" -f1 | rev)
expectedFile="Tests/SourceFiles/Expected/${fileName}"
if [ -f $expectedFile ]; then
cp "$file" $expectedFile
fileName="$(echo "$file" | awk -F"/" '{print $NF}')"
expectedFile="Tests/SourceFiles/Expected/$fileName"
if [ -f "$expectedFile" ]; then
cp "$file" "$expectedFile"
fi
done
done

View File

@ -1,8 +1,9 @@
#!/usr/bin/env bash
if [ "$1" != "--no-build" ]; then
FILE_NAME="cuckoo_generator.app"
if [[ "$1" != "--no-build" && -f "$FILE_NAME"]]; then
rm -rf Build
mkdir Build
xcodebuild -project 'CuckooGenerator.xcodeproj' -scheme 'CuckooGenerator' -configuration 'Release' CONFIGURATION_BUILD_DIR=$(pwd)/Build clean build
xcodebuild -project 'CuckooGenerator.xcodeproj' -scheme 'CuckooGenerator' -configuration 'Release' CONFIGURATION_BUILD_DIR="$PWD/Build" clean build
fi
cd Tests
cucumber
cucumber

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 SwiftKit
Copyright (c) 2016 Brightify.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -65,26 +65,26 @@ pod "Cuckoo"
And add the following `Run script` build phase to your test target's `Build Phases`:
```Bash
# Define output file; change "${PROJECT_NAME}Tests" to your test's root source folder, if it's not the default name
OUTPUT_FILE="./${PROJECT_NAME}Tests/GeneratedMocks.swift"
echo "Generated Mocks File = ${OUTPUT_FILE}"
# Define output file. Change "$PROJECT_DIR/Tests" to your test's root source folder, if it's not the default name.
OUTPUT_FILE="$PROJECT_DIR/Tests/GeneratedMocks.swift"
echo "Generated Mocks File = $OUTPUT_FILE"
# Define input directory; change "${PROJECT_NAME}" to your project's root source folder, if it's not the default name
INPUT_DIR="./${PROJECT_NAME}"
echo "Mocks Input Directory = ${INPUT_DIR}"
# Define input directory. Change "$PROJECT_DIR" to your project's root source folder, if it's not the default name.
INPUT_DIR="$PROJECT_DIR"
echo "Mocks Input Directory = $INPUT_DIR"
# Generate mock files; include as many input files as you'd like to create mocks for
${PODS_ROOT}/Cuckoo/run generate --testable "${PROJECT_NAME}" \
# Generate mock files, include as many input files as you'd like to create mocks for.
${PODS_ROOT}/Cuckoo/run generate --testable "$PROJECT_NAME" \
--output "${OUTPUT_FILE}" \
"${INPUT_DIR}/FileName1.swift" \
"${INPUT_DIR}/FileName2.swift" \
"${INPUT_DIR}/FileName3.swift"
"$INPUT_DIR/FileName1.swift" \
"$INPUT_DIR/FileName2.swift" \
"$INPUT_DIR/FileName3.swift"
# ... and so forth
# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group
# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group.
```
Input files can be also specified directly in `Run script` in `Input Files` form.
Input files can be also specified directly in `Run script` in `Input Files` form. To force run script to rebuild generator even if it already exists, use `--clean` as first argument.
#### Carthage
To use Cuckoo with [Carthage](https://github.com/Carthage/Carthage) add in your Cartfile this line:

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
FILE_NAME=cuckoo_generator.app
FILE_NAME="cuckoo_generator.app"
cd Generator
rm -rf Build
rm -rf $FILE_NAME
env -i PATH=${PATH}, HOME=${HOME} xcodebuild -project 'CuckooGenerator.xcodeproj' -scheme 'CuckooGenerator' -configuration 'Release' CONFIGURATION_BUILD_DIR=$(pwd)/Build clean build
mv Build/cuckoo_generator.app $FILE_NAME
rm -rf "$FILE_NAME"
env -i PATH="$PATH" HOME="$HOME" xcodebuild -project 'CuckooGenerator.xcodeproj' -scheme 'CuckooGenerator' -configuration 'Release' CONFIGURATION_BUILD_DIR="$PWD/Build" clean build
mv Build/cuckoo_generator.app "$FILE_NAME"
cd ..

32
run
View File

@ -1,18 +1,28 @@
#!/usr/bin/env bash
SCRIPT_PATH="`dirname \"$0\"`"
FILE_NAME=cuckoo_generator.app
FILE_PATH=$SCRIPT_PATH/Generator/$FILE_NAME
if [ ! -e $FILE_PATH ]; then
CURRENT_PWD=$(pwd)
cd $SCRIPT_PATH
SCRIPT_PATH="$(dirname "$0")"
FILE_NAME="cuckoo_generator.app"
FILE_PATH="$SCRIPT_PATH/Generator/$FILE_NAME"
if [[ "$1" = "--clean" || ! -e "$FILE_PATH" ]]; then
CURRENT_PWD="$PWD"
cd "$SCRIPT_PATH"
./build_generator
cd $CURRENT_PWD
cd "$CURRENT_PWD"
fi
if [[ "$1" = "--clean" ]]; then
shift
fi
INPUT_FILES=""
for (( i=0; i<SCRIPT_INPUT_FILE_COUNT; i++ ))
if [[ "$#" > 0 ]]; then
INPUT_FILES=$(printf '%q ' "$@")
fi
for (( i=0; i<$SCRIPT_INPUT_FILE_COUNT; i++ ))
do
VARIABLE=SCRIPT_INPUT_FILE_${i}
INPUT_FILES+=" "${!VARIABLE}
INPUT_FILE="SCRIPT_INPUT_FILE_$i"
INPUT_FILES+=" $(printf '%q' "${!INPUT_FILE}")"
done
$FILE_PATH/Contents/MacOS/cuckoo_generator "$@" ${INPUT_FILES}
echo $INPUT_FILES | xargs "$FILE_PATH/Contents/MacOS/cuckoo_generator"