|
1 |
| -module Test.Spago.Publish (spec) where |
| 1 | +module Test.Spago.Publish |
| 2 | + ( doTheGitThing |
| 3 | + , spec |
| 4 | + ) |
| 5 | + where |
2 | 6 |
|
3 | 7 | import Test.Prelude
|
4 | 8 |
|
@@ -85,133 +89,100 @@ spec = Spec.around withTempDir do
|
85 | 89 | spago [ "fetch" ] >>= shouldBeSuccess
|
86 | 90 | spago [ "publish", "-p", "root", "--offline" ] >>= shouldBeFailureErr (fixture "publish/1307-publish-dependencies/expected-stderr.txt")
|
87 | 91 |
|
88 |
| - Spec.describe "transfer" do |
89 |
| - |
90 |
| - Spec.it "fails if the publish config is not specified" \{ spago, fixture } -> do |
91 |
| - spago [ "init", "--name", "aaaa" ] >>= shouldBeSuccess |
92 |
| - spago [ "registry", "transfer", "--offline", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeFailureErr (fixture "publish/transfer/no-publish-config.txt") |
93 |
| - |
94 |
| - Spec.it "fails if the config does not specify an owner" \{ spago, fixture, testCwd } -> do |
95 |
| - FS.copyFile { src: fixture "publish/basic.yaml", dst: testCwd </> "spago.yaml" } |
| 92 | + Spec.it "#1110 installs versions of packages that are returned by the registry solver, but not present in cache" \{ spago, fixture, testCwd } -> do |
| 93 | + let |
| 94 | + shouldBeFailureErr' file = checkOutputs' |
| 95 | + { stdoutFile: Nothing |
| 96 | + , stderrFile: Just file |
| 97 | + , result: isLeft |
| 98 | + , sanitize: |
| 99 | + String.trim |
| 100 | + >>> String.replaceAll (String.Pattern "\\") (String.Replacement "/") |
| 101 | + >>> String.replaceAll (String.Pattern "\r\n") (String.Replacement "\n") |
| 102 | + >>> Regex.replace buildOrderRegex "[x of 3] Compiling module-name" |
| 103 | + } |
| 104 | + |
| 105 | + -- We have to ignore lines like "[1 of 3] Compiling Effect.Console" when |
| 106 | + -- comparing output, because the compiler will always compile in |
| 107 | + -- different order, depending on how the system resources happened to |
| 108 | + -- align at the moment of the test run. |
| 109 | + buildOrderRegex = unsafeFromRight $ Regex.regex |
| 110 | + "\\[\\d of 3\\] Compiling (Effect\\.Console|Effect\\.Class\\.Console|Lib)" |
| 111 | + RF.global |
| 112 | + |
| 113 | + FS.copyTree { src: fixture "publish/1110-solver-different-version", dst: testCwd } |
96 | 114 | spago [ "build" ] >>= shouldBeSuccess
|
97 |
| - spago [ "registry", "transfer", "--offline", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeFailureErr (fixture "publish/transfer/no-owner.txt") |
98 |
| - |
99 |
| - Spec.it "fails if the git tree is not clean" \{ spago, fixture, testCwd } -> do |
100 |
| - FS.copyFile { src: fixture "publish/basic.yaml", dst: testCwd </> "spago.yaml" } |
101 |
| - spago [ "auth", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeSuccess |
102 |
| - spago [ "registry", "transfer", "--offline", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeFailureErr (fixture "publish/transfer/no-git.txt") |
103 |
| - |
104 |
| - Spec.it "fails if the package has never been published before" \{ spago, fixture, testCwd } -> do |
105 |
| - FS.copyFile { src: fixture "publish/basic.yaml", dst: testCwd </> "spago.yaml" } |
106 |
| - spago [ "auth", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeSuccess |
107 |
| - doTheGitThing |
108 |
| - spago [ "registry", "transfer", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeFailureErr (fixture "publish/transfer/never-published.txt") |
109 |
| - |
110 |
| - Spec.it "fails if the new repo location is the same as the current one in the registry" \{ spago, fixture, testCwd } -> do |
111 |
| - FS.copyFile { src: fixture "publish/transfer/aff.yaml", dst: testCwd </> "spago.yaml" } |
112 |
| - spago [ "auth", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeSuccess |
113 | 115 | doTheGitThing
|
114 |
| - spago [ "registry", "transfer", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeFailureErr (fixture "publish/transfer/same-location.txt") |
| 116 | + spago [ "fetch" ] >>= shouldBeSuccess |
115 | 117 |
|
116 |
| - Spec.it "fails if can't find the private key" \{ spago, fixture, testCwd } -> do |
117 |
| - FS.copyFile { src: fixture "publish/transfer/aff-new-location.yaml", dst: testCwd </> "spago.yaml" } |
118 |
| - spago [ "auth", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeSuccess |
| 118 | + -- The local `spago.yaml` specifies `console: 6.0.0` in `extraPackages`, |
| 119 | + -- so that's what should be in local cache after running `fetch`. |
| 120 | + -- Importantly, `console-6.1.0` should not be there yet. |
| 121 | + FS.exists (testCwd </> ".spago/p/console-6.0.0") >>= (_ `shouldEqual` true) |
| 122 | + FS.exists (testCwd </> ".spago/p/console-6.1.0") >>= (_ `shouldEqual` false) |
| 123 | + |
| 124 | + spago [ "publish", "--offline" ] >>= shouldBeFailureErr' (fixture "publish/1110-solver-different-version/expected-stderr.txt") |
| 125 | + |
| 126 | + -- When `publish` runs, it uses the registry solver, which returns |
| 127 | + -- `console-6.1.0` version, so `publish` should fetch that into local |
| 128 | + -- cache and build with it. |
| 129 | + FS.exists (testCwd </> ".spago/p/console-6.1.0") >>= (_ `shouldEqual` true) |
| 130 | + |
| 131 | + -- Now screw up the `console-6.1.0` package in the local cache, so that it |
| 132 | + -- doesn't compile anymore, and check that the relevant compile error |
| 133 | + -- happens on publish. |
| 134 | + FS.unlink $ testCwd </> ".spago/p/console-6.1.0/src/Effect/Console.js" |
| 135 | + rmRf $ testCwd </> ".spago/p/console-6.1.0/output" |
| 136 | + spago [ "publish", "--offline" ] >>= shouldBeFailureErr' (fixture "publish/1110-solver-different-version/failure-stderr.txt") |
| 137 | + |
| 138 | + Spec.describe "#1060 auto-filling the `publish.location` field" do |
| 139 | + let |
| 140 | + prepareProject spago fixture testCwd = do |
| 141 | + FS.copyTree { src: fixture "publish/1060-autofill-location/project", dst: testCwd } |
| 142 | + spago [ "build" ] >>= shouldBeSuccess |
| 143 | + doTheGitThing |
| 144 | + spago [ "fetch" ] >>= shouldBeSuccess |
| 145 | + |
| 146 | + Spec.it "happens for root package" \{ fixture, spago, testCwd } -> do |
| 147 | + prepareProject spago fixture testCwd |
| 148 | + spago [ "publish", "-p", "aaa", "--offline" ] >>= |
| 149 | + shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-root/expected-stderr.txt") |
| 150 | + checkFixture (testCwd </> "spago.yaml") |
| 151 | + (fixture "publish/1060-autofill-location/scenario-root/expected-spago.yaml") |
| 152 | + |
| 153 | + Spec.it "errors out for non-root package" \{ fixture, spago, testCwd } -> do |
| 154 | + prepareProject spago fixture testCwd |
| 155 | + spago [ "publish", "-p", "bbb", "--offline" ] >>= |
| 156 | + shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-subdir/expected-stderr.txt") |
| 157 | + |
| 158 | + Spec.it "errors out for nested non-root package" \{ fixture, spago, testCwd } -> do |
| 159 | + prepareProject spago fixture testCwd |
| 160 | + spago [ "publish", "-p", "ccc", "--offline" ] >>= |
| 161 | + shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-nested-subdir/expected-stderr.txt") |
| 162 | + |
| 163 | + Spec.it "errors out when not a GitHub remote" \{ fixture, spago, testCwd } -> do |
| 164 | + prepareProject spago fixture testCwd |
| 165 | + git [ "remote", "set-url", "origin", "https://not.git-hub.net/foo/bar.git" ] |
| 166 | + spago [ "publish", "-p", "aaa", "--offline" ] >>= |
| 167 | + shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-non-github/expected-stderr.txt") |
| 168 | + checkFixture (testCwd </> "spago.yaml") |
| 169 | + (fixture "publish/1060-autofill-location/scenario-non-github/expected-spago.yaml") |
| 170 | + |
| 171 | + Spec.it "prints error when no origin remote" \{ fixture, spago, testCwd } -> do |
| 172 | + prepareProject spago fixture testCwd |
| 173 | + git [ "remote", "remove", "origin" ] |
| 174 | + git [ "remote", "add", "upstream", "[email protected]:foo/bar.git" ] |
| 175 | + spago [ "publish", "-p", "aaa", "--offline" ] >>= |
| 176 | + shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-no-origin/expected-stderr.txt") |
| 177 | + checkFixture (testCwd </> "spago.yaml") |
| 178 | + (fixture "publish/1060-autofill-location/project/spago.yaml") |
| 179 | + |
| 180 | + Spec.it "#1109 fails if the checked out git tag does not match the publish config's version" \{ spago, fixture, testCwd } -> do |
| 181 | + FS.copyTree { src: fixture "publish/1109-tag-mismatch", dst: testCwd } |
| 182 | + spago [ "build" ] >>= shouldBeSuccess |
119 | 183 | doTheGitThing
|
120 |
| - spago [ "registry", "transfer", "-i", (Path.toRaw $ fixture "publish/no-key") ] >>= shouldBeFailureErr (fixture "publish/transfer/no-key.txt") |
| 184 | + spago [ "publish", "--offline" ] >>= shouldBeFailureErr (fixture "publish/1109-tag-mismatch/expected-stderr.txt") |
121 | 185 |
|
122 |
| - Spec.it "fails if running with --offline" \{ spago, fixture, testCwd } -> do |
123 |
| - FS.copyFile { src: fixture "publish/transfer/aff-new-location.yaml", dst: testCwd </> "spago.yaml" } |
124 |
| - spago [ "auth", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeSuccess |
125 |
| - doTheGitThing |
126 |
| - spago [ "registry", "transfer", "--offline", "-i", (Path.toRaw $ fixture "publish/key") ] >>= shouldBeFailureErr (fixture "publish/transfer/offline.txt") |
127 |
| - |
128 |
| - Spec.it "#1110 installs versions of packages that are returned by the registry solver, but not present in cache" \{ spago, fixture, testCwd } -> do |
129 |
| - let |
130 |
| - shouldBeFailureErr' file = checkOutputs' |
131 |
| - { stdoutFile: Nothing |
132 |
| - , stderrFile: Just file |
133 |
| - , result: isLeft |
134 |
| - , sanitize: |
135 |
| - String.trim |
136 |
| - >>> String.replaceAll (String.Pattern "\\") (String.Replacement "/") |
137 |
| - >>> String.replaceAll (String.Pattern "\r\n") (String.Replacement "\n") |
138 |
| - >>> Regex.replace buildOrderRegex "[x of 3] Compiling module-name" |
139 |
| - } |
140 |
| - |
141 |
| - -- We have to ignore lines like "[1 of 3] Compiling Effect.Console" when |
142 |
| - -- comparing output, because the compiler will always compile in |
143 |
| - -- different order, depending on how the system resources happened to |
144 |
| - -- align at the moment of the test run. |
145 |
| - buildOrderRegex = unsafeFromRight $ Regex.regex |
146 |
| - "\\[\\d of 3\\] Compiling (Effect\\.Console|Effect\\.Class\\.Console|Lib)" |
147 |
| - RF.global |
148 |
| - |
149 |
| - FS.copyTree { src: fixture "publish/1110-solver-different-version", dst: testCwd } |
150 |
| - spago [ "build" ] >>= shouldBeSuccess |
151 |
| - doTheGitThing |
152 |
| - spago [ "fetch" ] >>= shouldBeSuccess |
153 |
| - |
154 |
| - -- The local `spago.yaml` specifies `console: 6.0.0` in `extraPackages`, |
155 |
| - -- so that's what should be in local cache after running `fetch`. |
156 |
| - -- Importantly, `console-6.1.0` should not be there yet. |
157 |
| - FS.exists (testCwd </> ".spago/p/console-6.0.0") >>= (_ `shouldEqual` true) |
158 |
| - FS.exists (testCwd </> ".spago/p/console-6.1.0") >>= (_ `shouldEqual` false) |
159 |
| - |
160 |
| - spago [ "publish", "--offline" ] >>= shouldBeFailureErr' (fixture "publish/1110-solver-different-version/expected-stderr.txt") |
161 |
| - |
162 |
| - -- When `publish` runs, it uses the registry solver, which returns |
163 |
| - -- `console-6.1.0` version, so `publish` should fetch that into local |
164 |
| - -- cache and build with it. |
165 |
| - FS.exists (testCwd </> ".spago/p/console-6.1.0") >>= (_ `shouldEqual` true) |
166 |
| - |
167 |
| - -- Now screw up the `console-6.1.0` package in the local cache, so that it |
168 |
| - -- doesn't compile anymore, and check that the relevant compile error |
169 |
| - -- happens on publish. |
170 |
| - FS.unlink $ testCwd </> ".spago/p/console-6.1.0/src/Effect/Console.js" |
171 |
| - rmRf $ testCwd </> ".spago/p/console-6.1.0/output" |
172 |
| - spago [ "publish", "--offline" ] >>= shouldBeFailureErr' (fixture "publish/1110-solver-different-version/failure-stderr.txt") |
173 |
| - |
174 |
| - Spec.describe "#1060 auto-filling the `publish.location` field" do |
175 |
| - let |
176 |
| - prepareProject spago fixture testCwd = do |
177 |
| - FS.copyTree { src: fixture "publish/1060-autofill-location/project", dst: testCwd } |
178 |
| - spago [ "build" ] >>= shouldBeSuccess |
179 |
| - doTheGitThing |
180 |
| - spago [ "fetch" ] >>= shouldBeSuccess |
181 |
| - |
182 |
| - Spec.it "happens for root package" \{ fixture, spago, testCwd } -> do |
183 |
| - prepareProject spago fixture testCwd |
184 |
| - spago [ "publish", "-p", "aaa", "--offline" ] >>= |
185 |
| - shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-root/expected-stderr.txt") |
186 |
| - checkFixture (testCwd </> "spago.yaml") |
187 |
| - (fixture "publish/1060-autofill-location/scenario-root/expected-spago.yaml") |
188 |
| - |
189 |
| - Spec.it "errors out for non-root package" \{ fixture, spago, testCwd } -> do |
190 |
| - prepareProject spago fixture testCwd |
191 |
| - spago [ "publish", "-p", "bbb", "--offline" ] >>= |
192 |
| - shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-subdir/expected-stderr.txt") |
193 |
| - |
194 |
| - Spec.it "errors out for nested non-root package" \{ fixture, spago, testCwd } -> do |
195 |
| - prepareProject spago fixture testCwd |
196 |
| - spago [ "publish", "-p", "ccc", "--offline" ] >>= |
197 |
| - shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-nested-subdir/expected-stderr.txt") |
198 |
| - |
199 |
| - Spec.it "errors out when not a GitHub remote" \{ fixture, spago, testCwd } -> do |
200 |
| - prepareProject spago fixture testCwd |
201 |
| - git [ "remote", "set-url", "origin", "https://not.git-hub.net/foo/bar.git" ] |
202 |
| - spago [ "publish", "-p", "aaa", "--offline" ] >>= |
203 |
| - shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-non-github/expected-stderr.txt") |
204 |
| - checkFixture (testCwd </> "spago.yaml") |
205 |
| - (fixture "publish/1060-autofill-location/scenario-non-github/expected-spago.yaml") |
206 |
| - |
207 |
| - Spec.it "prints error when no origin remote" \{ fixture, spago, testCwd } -> do |
208 |
| - prepareProject spago fixture testCwd |
209 |
| - git [ "remote", "remove", "origin" ] |
210 |
| - git [ "remote", "add", "upstream", "[email protected]:foo/bar.git" ] |
211 |
| - spago [ "publish", "-p", "aaa", "--offline" ] >>= |
212 |
| - shouldBeFailureErr (fixture "publish/1060-autofill-location/scenario-no-origin/expected-stderr.txt") |
213 |
| - checkFixture (testCwd </> "spago.yaml") |
214 |
| - (fixture "publish/1060-autofill-location/project/spago.yaml") |
215 | 186 |
|
216 | 187 | doTheGitThing :: Aff Unit
|
217 | 188 | doTheGitThing = do
|
|
0 commit comments