@@ -9,54 +9,63 @@ trait RunGistTestDefinitions { _: RunTestDefinitions =>
9
9
if (Properties .isWin) " \" " + url + " \" "
10
10
else url
11
11
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
+ }
34
30
}
35
- }
36
31
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
+ }
46
42
}
47
- }
48
43
49
- test(" Github Gists Script URL" ) {
50
- TestUtil .retryOnCi() {
44
+ test(s " Java URL $useFileDirectiveMessage" ) {
51
45
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))
56
50
.call(cwd = root)
57
51
.out.trim()
58
52
expect(output == message)
59
53
}
60
54
}
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
+ }
61
70
}
62
71
}
0 commit comments