@@ -9,54 +9,63 @@ trait RunGistTestDefinitions { _: RunTestDefinitions =>
99 if (Properties .isWin) " \" " + url + " \" "
1010 else url
1111
12- protected val scalaScriptUrl =
13- " https://gist.github.com/alexarchambault/f972d941bc4a502d70267cfbbc4d6343/raw/b0285fa0305f76856897517b06251970578565af/test.sc"
14- protected val scalaScriptMessage = " Hello from GitHub Gist"
15-
16- test(" Script URL" ) {
17- emptyInputs.fromRoot { root =>
18- val output = os.proc(TestUtil .cli, extraOptions, escapedUrls(scalaScriptUrl))
19- .call(cwd = root)
20- .out.trim()
21- expect(output == scalaScriptMessage)
22- }
23- }
24-
25- test(" Scala URL" ) {
26- val url =
27- " https://gist.github.com/alexarchambault/f972d941bc4a502d70267cfbbc4d6343/raw/2691c01984c9249936a625a42e29a822a357b0f6/Test.scala"
28- val message = " Hello from Scala GitHub Gist"
29- emptyInputs.fromRoot { root =>
30- val output = os.proc(TestUtil .cli, extraOptions, escapedUrls(url))
31- .call(cwd = root)
32- .out.trim()
33- expect(output == message)
12+ for {
13+ useFileDirective <- Seq (true , false )
14+ useFileDirectiveMessage = if (useFileDirective) " (//> using file)" else " "
15+ } {
16+ def testInputs (url : String ) =
17+ if (useFileDirective) TestInputs (os.rel / " input.scala" -> s " //> using file $url" )
18+ else emptyInputs
19+ def args (url : String ) = if (useFileDirective) Seq (" ." ) else Seq (escapedUrls(url))
20+ test(s " Script URL $useFileDirectiveMessage" ) {
21+ val url =
22+ " https://gist.github.com/alexarchambault/f972d941bc4a502d70267cfbbc4d6343/raw/b0285fa0305f76856897517b06251970578565af/test.sc"
23+ val expectedMessage = " Hello from GitHub Gist"
24+ testInputs(url).fromRoot { root =>
25+ val output = os.proc(TestUtil .cli, " run" , extraOptions, args(url))
26+ .call(cwd = root)
27+ .out.trim()
28+ expect(output == expectedMessage)
29+ }
3430 }
35- }
3631
37- test(" Java URL" ) {
38- val url =
39- " https://gist.github.com/alexarchambault/f972d941bc4a502d70267cfbbc4d6343/raw/2691c01984c9249936a625a42e29a822a357b0f6/Test.java"
40- val message = " Hello from Java GitHub Gist"
41- emptyInputs.fromRoot { root =>
42- val output = os.proc(TestUtil .cli, extraOptions, escapedUrls(url))
43- .call(cwd = root)
44- .out.trim()
45- expect(output == message)
32+ test(s " Scala URL $useFileDirectiveMessage" ) {
33+ val url =
34+ " https://gist.github.com/alexarchambault/f972d941bc4a502d70267cfbbc4d6343/raw/2691c01984c9249936a625a42e29a822a357b0f6/Test.scala"
35+ val message = " Hello from Scala GitHub Gist"
36+ testInputs(url).fromRoot { root =>
37+ val output = os.proc(TestUtil .cli, extraOptions, args(url))
38+ .call(cwd = root)
39+ .out.trim()
40+ expect(output == message)
41+ }
4642 }
47- }
4843
49- test(" Github Gists Script URL" ) {
50- TestUtil .retryOnCi() {
44+ test(s " Java URL $useFileDirectiveMessage" ) {
5145 val url =
52- " https://gist.github.com/alexarchambault/7b4ec20c4033690dd750ffd601e540ec "
53- val message = " Hello"
54- emptyInputs .fromRoot { root =>
55- val output = os.proc(TestUtil .cli, extraOptions, escapedUrls (url))
46+ " https://gist.github.com/alexarchambault/f972d941bc4a502d70267cfbbc4d6343/raw/2691c01984c9249936a625a42e29a822a357b0f6/Test.java "
47+ val message = " Hello from Java GitHub Gist "
48+ testInputs(url) .fromRoot { root =>
49+ val output = os.proc(TestUtil .cli, extraOptions, args (url))
5650 .call(cwd = root)
5751 .out.trim()
5852 expect(output == message)
5953 }
6054 }
55+
56+ if (! useFileDirective) // TODO: add support for gists in using file directives
57+ test(s " Github Gists Script URL $useFileDirectiveMessage" ) {
58+ TestUtil .retryOnCi() {
59+ val url =
60+ " https://gist.github.com/alexarchambault/7b4ec20c4033690dd750ffd601e540ec"
61+ val message = " Hello"
62+ testInputs(url).fromRoot { root =>
63+ val output = os.proc(TestUtil .cli, extraOptions, args(url))
64+ .call(cwd = root)
65+ .out.trim()
66+ expect(output == message)
67+ }
68+ }
69+ }
6170 }
6271}
0 commit comments