Skip to content

Commit

Permalink
Rename using lib directive to using dep
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Feb 2, 2023
1 parent 7df5441 commit 4554a16
Show file tree
Hide file tree
Showing 57 changed files with 190 additions and 188 deletions.
2 changes: 1 addition & 1 deletion examples/junit/MyTests.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using lib "com.github.sbt:junit-interface:0.13.2"
//> using dep "com.github.sbt:junit-interface:0.13.2"
import org.junit.Test

class MyTests {
Expand Down
2 changes: 1 addition & 1 deletion examples/scala-files/simple.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using lib "com.lihaoyi::pprint:0.8.1"
//> using dep "com.lihaoyi::pprint:0.8.1"

object Test {
def something[F[_]] = ()
Expand Down
2 changes: 1 addition & 1 deletion examples/scalatest/Tests.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using lib "org.scalatest::scalatest::3.2.9"
//> using dep "org.scalatest::scalatest::3.2.9"

import org.scalatest._
import flatspec._
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/MyTests.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using lib "org.scalameta::munit::0.7.29"
//> using dep "org.scalameta::munit::0.7.29"

class MyTests extends munit.FunSuite {
test("foo") {
Expand Down
2 changes: 1 addition & 1 deletion examples/utest/MyTests.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using lib "com.lihaoyi::utest::0.7.10"
//> using dep "com.lihaoyi::utest::0.7.10"

import utest._

Expand Down
4 changes: 2 additions & 2 deletions gcbenchmark/gcbenchmark.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//> using lib "com.lihaoyi::os-lib:0.8.0"
//> using lib "com.lihaoyi::pprint:0.7.1"
//> using dep "com.lihaoyi::os-lib:0.8.0"
//> using dep "com.lihaoyi::pprint:0.7.1"
//> using scala "2.13"

// Usage: scala-cli gcbenchmark.scala -- <path_to_scala_cli_executable>
Expand Down
2 changes: 1 addition & 1 deletion gifs/create_missing.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env scala-cli

//> using lib "com.lihaoyi::os-lib:0.7.8"
//> using dep "com.lihaoyi::os-lib:0.7.8"

/** Small and handy script to generate stubs for .svg files with nice TODO
*/
Expand Down
4 changes: 2 additions & 2 deletions gifs/scenarios/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [[ -z "${ASCIINEMA_REC}" ]]; then
# Warm up scala-cli
echo "println(1)" | scala-cli -
cat <<EOF > demo.test.scala |
//> using lib "org.scalameta::munit:0.7.29"
//> using dep "org.scalameta::munit:0.7.29"
EOF
scala-cli test demo.test.scala
# or do other preparation (e.g. create code)
Expand Down Expand Up @@ -56,7 +56,7 @@ EOF
clearConsole

cat <<EOF | updateFile demo.test.scala
//> using lib "org.scalameta::munit:0.7.29"
//> using dep "org.scalameta::munit:0.7.29"
class demoTest extends munit.FunSuite {
test("test nice args") {
Expand Down
8 changes: 4 additions & 4 deletions gifs/scenarios/powerful_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)

if [[ -z "${ASCIINEMA_REC}" ]]; then
# Warm up scala-cli
echo '//> using lib "com.lihaoyi::os-lib:0.7.8"' | scala-cli -
echo '//> using lib "com.lihaoyi::pprint:0.6.6"' | scala-cli -
echo '//> using dep "com.lihaoyi::os-lib:0.7.8"' | scala-cli -
echo '//> using dep "com.lihaoyi::pprint:0.6.6"' | scala-cli -
# or do other preparation (e.g. create code)
else
. $SCRIPT_DIR/../demo-magic.sh
Expand All @@ -20,8 +20,8 @@ else

# Put your stuff here
cat <<EOF | updateFile stat.sc
//> using lib "com.lihaoyi::os-lib:0.7.8"
//> using lib "com.lihaoyi::pprint:0.6.6"
//> using dep "com.lihaoyi::os-lib:0.7.8"
//> using dep "com.lihaoyi::pprint:0.6.6"
import pprint._
import os._
Expand Down
4 changes: 2 additions & 2 deletions gifs/scenarios/projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
if [[ -z "${ASCIINEMA_REC}" ]]; then
# Warm up scala-cli
echo "println(1)" | scala-cli -S 2.13.6 -
echo "//> using lib \"com.softwaremill.sttp.client3::core:3.3.18\" " | scala-cli -S 2.13.6 -
echo "//> using dep \"com.softwaremill.sttp.client3::core:3.3.18\" " | scala-cli -S 2.13.6 -
# or do other preparation (e.g. create code)
else
. $SCRIPT_DIR/../demo-magic.sh
Expand All @@ -20,7 +20,7 @@ else

# Put your stuff here
cat <<EOF | updateFile Post.scala
//> using lib "com.softwaremill.sttp.client3::core:3.3.18"
//> using dep "com.softwaremill.sttp.client3::core:3.3.18"
import sttp.client3._
// https://sttp.softwaremill.com/en/latest/quickstart.html
Expand Down
4 changes: 2 additions & 2 deletions gifs/scenarios/scripting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
if [[ -z "${ASCIINEMA_REC}" ]]; then
# Warm up scala-cli
echo "println(1)" | scala-cli -
echo "//> using lib \"com.lihaoyi::os-lib::0.7.8\"" | scala-cli -
echo "//> using dep \"com.lihaoyi::os-lib::0.7.8\"" | scala-cli -
# or do other preparation (e.g. create code)
else
. $SCRIPT_DIR/../demo-magic.sh
Expand All @@ -24,7 +24,7 @@ Hello World from file
EOF

cat <<EOF | updateFile script.sc
//> using lib "com.lihaoyi::os-lib::0.7.8"
//> using dep "com.lihaoyi::os-lib::0.7.8"
val filePath = os.pwd / "file"
val fileContent = os.read(filePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ case object ScalaPreprocessor extends Preprocessor {
(importStart, t) <- dependencyTrees
pos = toFilePos(Position.Raw(importStart, t.end))
dep = t.prefix.drop(1).mkString(".")
newImportText = s"//> using lib \"$dep\""
newImportText = s"//> using dep \"$dep\""
} yield new UnsupportedAmmoniteImportError(Seq(pos), newImportText)

Left(CompositeBuildException(exceptions))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ActionableDiagnosticTests extends munit.FunSuite {
val dependencyOsLib = "com.lihaoyi::os-lib:0.7.8"
val testInputs = TestInputs(
os.rel / "Foo.scala" ->
s"""//> using lib "$dependencyOsLib"
s"""//> using dep "$dependencyOsLib"
|
|object Hello extends App {
| println("Hello")
Expand Down Expand Up @@ -77,9 +77,9 @@ class ActionableDiagnosticTests extends munit.FunSuite {
expect(exceptions.length == 2)
expect(exceptions.forall(_.isInstanceOf[UnsupportedAmmoniteImportError]))

expect(exceptions.head.textEdit.get.newText == s"//> using lib \"$dependencyOsLib\"")
expect(exceptions.head.textEdit.get.newText == s"//> using dep \"$dependencyOsLib\"")
expect(
exceptions.tail.head.textEdit.get.newText == s"//> using lib \"$dependencyUpickleLib\""
exceptions.tail.head.textEdit.get.newText == s"//> using dep \"$dependencyUpickleLib\""
)

val filePositions = exceptions.flatMap(_.positions.collect {
Expand All @@ -94,7 +94,7 @@ class ActionableDiagnosticTests extends munit.FunSuite {
test("actionable actions suggest update only to stable version") {
val testInputs = TestInputs(
os.rel / "Foo.scala" ->
s"""//> using lib "test-org::test-name-1:1.0.6"
s"""//> using dep "test-org::test-name-1:1.0.6"
|
|object Hello extends App {
| println("Hello")
Expand Down Expand Up @@ -157,7 +157,7 @@ class ActionableDiagnosticTests extends munit.FunSuite {
test("actionable actions should not suggest update to previous version") {
val testInputs = TestInputs(
os.rel / "Foo.scala" ->
s"""//> using lib "test-org::test-name-1:2.0.0-M1"
s"""//> using dep "test-org::test-name-1:2.0.0-M1"
|
|object Hello extends App {
| println("Hello")
Expand Down
16 changes: 8 additions & 8 deletions modules/build/src/test/scala/scala/build/tests/BuildTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite {
test("dependencies - using") {
val testInputs = TestInputs(
os.rel / "simple.sc" ->
"""//> using lib "com.lihaoyi::geny:0.6.5"
"""//> using dep "com.lihaoyi::geny:0.6.5"
|import geny.Generator
|val g = Generator("Hel", "lo")
|println(g.mkString)
Expand All @@ -299,14 +299,14 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite {
test("several dependencies - using") {
val testInputs = TestInputs(
os.rel / "simple.sc" ->
"""//> using lib "com.lihaoyi::geny:0.6.5"
|//> using lib "com.lihaoyi::pprint:0.6.6"
"""//> using dep "com.lihaoyi::geny:0.6.5"
|//> using dep "com.lihaoyi::pprint:0.6.6"
|import geny.Generator
|val g = Generator("Hel", "lo")
|pprint.log(g)
|""".stripMargin,
os.rel / "simple2.sc" ->
"""//> using lib "com.lihaoyi::geny:0.6.5", "com.lihaoyi::pprint:0.6.6"
"""//> using dep "com.lihaoyi::geny:0.6.5", "com.lihaoyi::pprint:0.6.6"
|import geny.Generator
|val g = Generator("Hel", "lo")
|pprint.log(g)
Expand Down Expand Up @@ -509,7 +509,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite {
test("Pass files with only commented directives as is to scalac") {
val testInputs = TestInputs(
os.rel / "Simple.scala" ->
"""//> using lib "com.lihaoyi::pprint:0.6.6"
"""//> using dep "com.lihaoyi::pprint:0.6.6"
|object Simple {
| def main(args: Array[String]): Unit =
| pprint.log("Hello " + "from tests")
Expand Down Expand Up @@ -617,7 +617,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite {

val inputs = TestInputs(
os.rel / "foo.scala" ->
s"""//> using lib "$usingDependency"
s"""//> using dep "$usingDependency"
|def foo = "bar"
|""".stripMargin
)
Expand Down Expand Up @@ -805,7 +805,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite {
test("Pin Scala 2 artifacts version") {
val inputs = TestInputs(
os.rel / "Foo.scala" ->
"""//> using lib "com.lihaoyi:ammonite_2.13.8:2.5.1-6-5fce97fb"
"""//> using dep "com.lihaoyi:ammonite_2.13.8:2.5.1-6-5fce97fb"
|//> using scala "2.13.5"
|
|object Foo {
Expand Down Expand Up @@ -835,7 +835,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite {
test("Pin Scala 3 artifacts version") {
val inputs = TestInputs(
os.rel / "Foo.scala" ->
"""//> using lib "com.lihaoyi:ammonite_3.1.1:2.5.1-6-5fce97fb"
"""//> using dep "com.lihaoyi:ammonite_3.1.1:2.5.1-6-5fce97fb"
|//> using scala "3.1.0"
|
|object Foo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class DirectiveParsingTest extends munit.FunSuite {

test("interpolator in dependency") {
val diags =
testDiagnostics("""//> using lib ivy"org.scala-sbt::io:1.6.0"""")(Error("interpolator"))
testDiagnostics("""//> using dep ivy"org.scala-sbt::io:1.6.0"""")(Error("interpolator"))
println(diags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DirectiveTests extends munit.FunSuite {
test("resolving position of lib directive") {
val testInputs = TestInputs(
os.rel / "simple.sc" ->
"""//> using lib "com.lihaoyi::utest:0.7.10"
"""//> using dep "com.lihaoyi::utest:0.7.10"
|""".stripMargin
)
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ScalaPreprocessorTests extends munit.FunSuite {
test("should respect using directives in a .scala file with the shebang line") {
TestInputs(os.rel / "Main.scala" ->
"""#!/usr/bin/env -S scala-cli shebang
|//> using lib "com.lihaoyi::os-lib::0.8.1"
|//> using dep "com.lihaoyi::os-lib::0.8.1"
|
|object Main {
| def main(args: Array[String]): Unit = {
Expand All @@ -33,7 +33,7 @@ class ScalaPreprocessorTests extends munit.FunSuite {
test("should respect using directives in a .sc file with the shebang line") {
TestInputs(os.rel / "sample.sc" ->
"""#!/usr/bin/env -S scala-cli shebang
|//> using lib "com.lihaoyi::os-lib::0.8.1"
|//> using dep "com.lihaoyi::os-lib::0.8.1"
|println(os.pwd)
|""".stripMargin).fromRoot { root =>
val scalaFile = SourceScalaFile(root, os.sub / "sample.sc")
Expand Down
38 changes: 19 additions & 19 deletions modules/build/src/test/scala/scala/build/tests/SourcesTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class SourcesTests extends munit.FunSuite {
test("dependencies in .scala - using") {
val testInputs = TestInputs(
os.rel / "something.scala" ->
"""//> using libs "org1:name1:1.1", "org2::name2:2.2"
|//> using lib "org3:::name3:3.3"
"""//> using deps "org1:name1:1.1", "org2::name2:2.2"
|//> using dep "org3:::name3:3.3"
|import scala.collection.mutable
|
|object Something {
Expand Down Expand Up @@ -74,8 +74,8 @@ class SourcesTests extends munit.FunSuite {
val testInputs = TestInputs(
os.rel / "something.scala" ->
"""//> using target.scope "test"
|//> using libs "org1:name1:1.1", "org2::name2:2.2"
|//> using lib "org3:::name3:3.3"
|//> using deps "org1:name1:1.1", "org2::name2:2.2"
|//> using dep "org3:::name3:3.3"
|import scala.collection.mutable
|
|object Something {
Expand Down Expand Up @@ -106,8 +106,8 @@ class SourcesTests extends munit.FunSuite {
test("dependencies in .test.scala - using") {
val testInputs = TestInputs(
os.rel / "something.test.scala" ->
"""//> using libs "org1:name1:1.1", "org2::name2:2.2"
|//> using lib "org3:::name3:3.3"
"""//> using deps "org1:name1:1.1", "org2::name2:2.2"
|//> using dep "org3:::name3:3.3"
|import scala.collection.mutable
|
|object Something {
Expand Down Expand Up @@ -138,8 +138,8 @@ class SourcesTests extends munit.FunSuite {
test("dependencies in test/name.scala") {
val files = Seq(
os.rel / "test" / "something.scala" ->
"""//> using libs "org1:name1:1.1", "org2::name2:2.2"
|//> using lib "org3:::name3:3.3"
"""//> using deps "org1:name1:1.1", "org2::name2:2.2"
|//> using dep "org3:::name3:3.3"
|import scala.collection.mutable
|
|object Something {
Expand Down Expand Up @@ -168,9 +168,9 @@ class SourcesTests extends munit.FunSuite {
test("dependencies in .scala - //> using") {
val testInputs = TestInputs(
os.rel / "something.scala" ->
"""//> using lib "org1:name1:1.1"
|//> using lib "org2::name2:2.2"
|//> using lib "org3:::name3:3.3"
"""//> using dep "org1:name1:1.1"
|//> using dep "org2::name2:2.2"
|//> using dep "org3:::name3:3.3"
|import scala.collection.mutable
|
|object Something {
Expand Down Expand Up @@ -206,9 +206,9 @@ class SourcesTests extends munit.FunSuite {
test("dependencies in .java - //> using") {
val testInputs = TestInputs(
os.rel / "Something.java" ->
"""//> using lib "org1:name1:1.1"
|//> using lib "org2::name2:2.2"
|//> using lib "org3:::name3:3.3"
"""//> using dep "org1:name1:1.1"
|//> using dep "org2::name2:2.2"
|//> using dep "org3:::name3:3.3"
|
|public class Something {
| public Int a = 1;
Expand Down Expand Up @@ -243,7 +243,7 @@ class SourcesTests extends munit.FunSuite {
test("should fail dependencies in .java with using keyword") {
val testInputs = TestInputs(
os.rel / "Something.java" ->
"""using lib "org3:::name3:3.3"
"""using dep "org3:::name3:3.3"
|
|public class Something {
| public Int a = 1;
Expand Down Expand Up @@ -350,7 +350,7 @@ class SourcesTests extends munit.FunSuite {
test("dependencies in .sc - using") {
val testInputs = TestInputs(
os.rel / "something.sc" ->
"""//> using libs "org1:name1:1.1", "org2::name2:2.2", "org3:::name3:3.3"
"""//> using deps "org1:name1:1.1", "org2::name2:2.2", "org3:::name3:3.3"
|import scala.collection.mutable
|
|def a = 1
Expand Down Expand Up @@ -384,9 +384,9 @@ class SourcesTests extends munit.FunSuite {
test("dependencies in .sc - //> using") {
val testInputs = TestInputs(
os.rel / "something.sc" ->
"""//> using lib "org1:name1:1.1"
|//> using lib "org2::name2:2.2"
|//> using lib "org3:::name3:3.3"
"""//> using dep "org1:name1:1.1"
|//> using dep "org2::name2:2.2"
|//> using dep "org3:::name3:3.3"
|import scala.collection.mutable
|
|def a = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MarkdownCodeBlockTests extends munit.FunSuite {

test("a test Scala snippet is extracted correctly from markdown") {
val code =
"""//> using lib "org.scalameta::munit:0.7.29"
"""//> using dep "org.scalameta::munit:0.7.29"
|class Test extends munit.FunSuite {
| assert(true)
|}""".stripMargin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class MarkdownCodeWrapperTests extends munit.FunSuite {

test("a test Scala snippet is wrapped correctly") {
val snippet =
"""//> using lib "org.scalameta::munit:0.7.29"
"""//> using dep "org.scalameta::munit:0.7.29"
|class Test extends munit.FunSuite {
| assert(true)
|}""".stripMargin
Expand All @@ -162,7 +162,7 @@ class MarkdownCodeWrapperTests extends munit.FunSuite {

test("multiple test Scala snippets are glued together correctly") {
val snippet1 =
"""//> using lib "org.scalameta::munit:0.7.29"
"""//> using dep "org.scalameta::munit:0.7.29"
|class Test1 extends munit.FunSuite {
| assert(true)
|}""".stripMargin
Expand Down
Loading

0 comments on commit 4554a16

Please sign in to comment.