|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# RunToolTests.sh |
| 4 | +# ObjectBox Swift |
| 5 | +# |
| 6 | +# Created by Uli Kusterer on 07.12.18. |
| 7 | +# |
| 8 | + |
| 9 | +echo -n "note: Starting tests at " |
| 10 | +date |
| 11 | + |
| 12 | +mydir=`dirname "$0"` |
| 13 | +itestdir="$mydir/../IntegrationTests/" |
| 14 | + |
| 15 | +test_target_num () { |
| 16 | + testname="$1" |
| 17 | + testname="${testname//[ \/]/_}" |
| 18 | + testdir="$itestdir/$2_$testname" |
| 19 | + mkdir "$testdir" |
| 20 | + if [ -f "EntityInfo.generated$2.swift" ]; then |
| 21 | + cp "EntityInfo.generated$2.swift" "$testdir/EntityInfo.generated.expected.swift" |
| 22 | + fi |
| 23 | + if [ -f "EntityInfo.generated$2_original.swift" ]; then |
| 24 | + cp "EntityInfo.generated$2_original.swift" "$testdir/EntityInfo.generated.initial.swift" |
| 25 | + fi |
| 26 | + if [ -f "messages$2.log" ]; then |
| 27 | + cp "messages$2.log" "$testdir/messages.expected.log" |
| 28 | + fi |
| 29 | + if [ -f "model$2.json" ]; then |
| 30 | + cp "model$2.json" "$testdir/model.expected.json" |
| 31 | + cp "model$2.json" "$testdir/model.initial.json" |
| 32 | + fi |
| 33 | + if [ -f "model$2_before.json" ]; then |
| 34 | + cp "model$2_before.json" "$testdir/model.initial.json" |
| 35 | + fi |
| 36 | + if [ -f "schemaDump$2.txt" ]; then |
| 37 | + cp "schemaDump$2.txt" "$testdir/schemaDump.expected.txt" |
| 38 | + fi |
| 39 | + if [ -f "schemaDump$2_original.txt" ]; then |
| 40 | + cp "schemaDump$2_original.txt" "$testdir/schemaDump_original.txt" |
| 41 | + fi |
| 42 | + if [ -f "ToolTestProject$2.swift" ]; then |
| 43 | + cp "ToolTestProject$2.swift" "$testdir/test.swift" |
| 44 | + fi |
| 45 | + if [ -f "ToolTestProject$2_original.swift" ]; then |
| 46 | + cp "ToolTestProject$2_original.swift" "$testdir/test_original.swift" |
| 47 | + fi |
| 48 | + if [ -f "xcode$2.log" ]; then |
| 49 | + cp "xcode$2.log" "$testdir/xcode.expected.log" |
| 50 | + fi |
| 51 | + cp -R "$itestdir/8_Empty_Entity/Project.xcodeproj" "$testdir/Project.xcodeproj" |
| 52 | +} |
| 53 | + |
| 54 | +fail_codegen_target_num () { |
| 55 | + testname="$1" |
| 56 | + testname="${testname//[ \/]/_}" |
| 57 | + testdir="$itestdir/$2_$testname" |
| 58 | + mkdir "$testdir" |
| 59 | + if [ -f "EntityInfo.generated$2.swift" ]; then |
| 60 | + cp "EntityInfo.generated$2.swift" "$testdir/EntityInfo.generated.expected.swift" |
| 61 | + fi |
| 62 | + if [ -f "EntityInfo.generated$2_original.swift" ]; then |
| 63 | + cp "EntityInfo.generated$2_original.swift" "$testdir/EntityInfo.generated.initial.swift" |
| 64 | + fi |
| 65 | + if [ -f "messages$2.log" ]; then |
| 66 | + cp "messages$2.log" "$testdir/messages.fail.log" |
| 67 | + fi |
| 68 | + if [ -f "model$2.json" ]; then |
| 69 | + cp "model$2.json" "$testdir/model.initial.json" |
| 70 | + fi |
| 71 | + if [ -f "model$2.before.json" ]; then |
| 72 | + if [ -f "$testdir/model.initial.json" ]; then |
| 73 | + echo "warning: model.before.json AND model.json found in ${2}_$testname" |
| 74 | + cp "model$2.before.json" "$testdir/model.initial2.json" |
| 75 | + else |
| 76 | + cp "model$2.json" "$testdir/model.expected.json" |
| 77 | + fi |
| 78 | + fi |
| 79 | + if [ -f "schemaDump$2.txt" ]; then |
| 80 | + cp "schemaDump$2.txt" "$testdir/schemaDump.initial.txt" |
| 81 | + fi |
| 82 | + if [ -f "schemaDump$2_original.txt" ]; then |
| 83 | + if [ -f "$testdir/schemaDump.initial.txt" ]; then |
| 84 | + echo "warning: schemaDump_before.txt AND schemaDump.txt found in ${2}_$testname" |
| 85 | + cp "schemaDump$2_original.txt" "$testdir/schemaDump.initial2.txt" |
| 86 | + else |
| 87 | + cp "schemaDump$2_original.txt" "$testdir/model.initial.txt" |
| 88 | + fi |
| 89 | + cp "schemaDump$2_original.txt" "$testdir/schemaDump_original.txt" |
| 90 | + fi |
| 91 | + if [ -f "ToolTestProject$2.swift" ]; then |
| 92 | + cp "ToolTestProject$2.swift" "$testdir/test.swift" |
| 93 | + fi |
| 94 | + if [ -f "ToolTestProject$2_original.swift" ]; then |
| 95 | + cp "ToolTestProject$2_original.swift" "$testdir/test_original.swift" |
| 96 | + fi |
| 97 | + if [ -f "xcode$2.log" ]; then |
| 98 | + cp "xcode$2.log" "$testdir/xcode.expected.log" |
| 99 | + fi |
| 100 | + cp -R "$itestdir/8_Empty_Entity/Project.xcodeproj" "$testdir/Project.xcodeproj" |
| 101 | +} |
| 102 | + |
| 103 | + |
| 104 | +cd "$mydir" |
| 105 | + |
| 106 | +test_target_num "ID and 2 strings entity" 9 || FAIL=1 |
| 107 | +fail_codegen_target_num "NameInDb collision with other property" 10 || FAIL=1 |
| 108 | +fail_codegen_target_num "Entity with string but no ID" 11 || FAIL=1 |
| 109 | +test_target_num "Remove A Property" 12 || FAIL=1 |
| 110 | +test_target_num "Remove A Property and add one at same time" 13 || FAIL=1 |
| 111 | +test_target_num "Add a Property after having removed one" 14 || FAIL=1 |
| 112 | +test_target_num "Remove an index from a property" 15 || FAIL=1 |
| 113 | +test_target_num "Add and remove an index in one go" 16 || FAIL=1 |
| 114 | +test_target_num "Add an index after having removed one" 17 || FAIL=1 |
| 115 | +test_target_num "Rename an entity" 18 || FAIL=1 |
| 116 | +fail_codegen_target_num "Entity UID printing" 19 || FAIL=1 |
| 117 | +fail_codegen_target_num "New Entity with empty UID" 20 || FAIL=1 |
| 118 | +test_target_num "Rename a property" 21 || FAIL=1 |
| 119 | +fail_codegen_target_num "Property UID printing" 22 || FAIL=1 |
| 120 | +fail_codegen_target_num "New Property with empty UID" 23 || FAIL=1 |
| 121 | +fail_codegen_target_num "New Property with UID" 24 || FAIL=1 |
| 122 | +test_target_num "Read/write all our data types" 25 || FAIL=1 |
| 123 | +test_target_num "Ensure running codegen on unchanged file changes nothing" 26 || FAIL=1 |
| 124 | +test_target_num "Ensure assigning a previously proposed UID works [Change/Reset]" 27 || FAIL=1 |
| 125 | +test_target_num "Ensure moving properties changes nothing" 28 || FAIL=1 |
| 126 | +test_target_num "Ensure moving entities changes nothing" 29 || FAIL=1 |
| 127 | +test_target_num "Unique Entity Exception Test" 30 || FAIL=1 |
| 128 | +test_target_num "Struct Entity Test" 31 || FAIL=1 |
| 129 | +test_target_num "UInt64 as ID Test" 32 || FAIL=1 |
| 130 | +test_target_num "Data and [UInt8] Test" 33 || FAIL=1 |
| 131 | + |
| 132 | +test_target_num "Converter Test" 34 || FAIL=1 |
| 133 | +test_target_num "Enum Test" 35 || FAIL=1 |
| 134 | +test_target_num "Standalone Relations" 36 || FAIL=1 |
| 135 | +test_target_num "Standalone Backlinks" 37 || FAIL=1 |
| 136 | +test_target_num "Edit ToOne Backlinks" 38 || FAIL=1 |
| 137 | +test_target_num "Edit ToOne Backlinks Structs" 39 || FAIL=1 |
| 138 | +test_target_num "Standalone Backlinks Structs" 40 || FAIL=1 |
| 139 | +fail_codegen_target_num "ToOne Backlink annotation wrong" 41 || FAIL=1 |
| 140 | +test_target_num "Standalone Relation Queries" 42 || FAIL=1 |
| 141 | +test_target_num "ToOne Relation Queries" 43 || FAIL=1 |
| 142 | +test_target_num "many-to-many reset" 44 || FAIL=1 |
| 143 | +test_target_num "many-to-many backlink reset" 45 || FAIL=1 |
| 144 | +test_target_num "Threaded ToOne backlink edit" 46 || FAIL=1 |
| 145 | +test_target_num "Threaded Many-to-many edit" 47 || FAIL=1 |
| 146 | +test_target_num "Threaded Many-to-many backlink edit" 48 || FAIL=1 |
| 147 | +test_target_num "Untyped IDs and queries 1" 49 || FAIL=1 |
| 148 | +test_target_num "Untyped IDs and queries 2" 50 || FAIL=1 |
| 149 | +#fail_codegen_target_num "Typed IDs still enforce type?" 51 || FAIL=1 |
| 150 | + |
| 151 | +fail_codegen_target_num "Ensure we don't write JSON before ID errors" 52 || FAIL=1 |
| 152 | +test_target_num "ToOne Backlink ensure applyToDb is needed" 53 || FAIL=1 |
| 153 | +test_target_num "ToMany ensure applyToDb is needed" 54 || FAIL=1 |
| 154 | +test_target_num "ToMany Backlink ensure applyToDb is needed" 55 || FAIL=1 |
| 155 | +test_target_num "Swift Property Wrappers are treated as wrapped type" 56 || FAIL=1 |
| 156 | + |
| 157 | +echo "note: Finished tests..." |
| 158 | + |
| 159 | +exit $FAIL |
0 commit comments