Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup-ide should run before compile, run and test #188

Merged
merged 16 commits into from
Oct 15, 2021

Conversation

MarcinAman
Copy link
Contributor

No description provided.

@MarcinAman MarcinAman marked this pull request as ready for review October 5, 2021 15:23
@MarcinAman MarcinAman marked this pull request as draft October 5, 2021 15:24
@MarcinAman MarcinAman marked this pull request as ready for review October 7, 2021 11:35
modules/cli/src/main/scala/scala/cli/commands/Run.scala Outdated Show resolved Hide resolved
modules/cli/src/main/scala/scala/cli/commands/Test.scala Outdated Show resolved Hide resolved

val importPprintOnlyProject = TestInputs(
Seq(
os.rel / "simple.sc" -> s"import $$ivy.`com.lihaoyi::pprint:${Constants.pprintVersion}`"
)
)

test("setup-ide should have only absolute path if relative one was specified") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this tests. Plus the handling of the os.Paths looks suspicious (all os.Paths are absolute and normalized).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue that i wanted to solve is whenever i run something like scala-cli setup-ide ../other/folder -S 3.0.1 in the directory that is not within a project then the scala-cli.json contains relative path that i posted. This is wrong as the paths (if we want relative one) should be resolved from the workspace not from the place where i run scala-cli. Therefore i thought that it would be safe to always include absolute paths just like we do when path to scala-cli is relative.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be exact this is what scala-cli outputs:

{
  "name": "sbt",
  "argv": [
    "scala-cli",
    "bsp",
    "../example/scala3",
    "-S",
    "3.0.1",
    "--bsp-name",
    "sbt"
  ],
  "version": "0.0.4-SNAPSHOT",
  "bspVersion": "2.0.0-M13",
  "languages": [
    "scala",
    "java"
  ]
}

When i run from: ~/Documents/scala-cli and have an example project in ~/Documents/example/scala3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Weird, I thought I had answered this in an earlier review, but I can't see my answers here… Anyway, that was a good point ^^)

@MarcinAman MarcinAman force-pushed the setup-ide-before-all branch 4 times, most recently from 82d6a9e to b69886d Compare October 12, 2021 09:56
modules/cli/src/main/scala/scala/cli/commands/Bsp.scala Outdated Show resolved Hide resolved
os.FilePath(rawArgv(0)).resolveFrom(Os.pwd).toString
else {
val absoluteScalaCliPath =
this.getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath.trim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is going to work from the native executables… (it should throw an NPE I think).

Using just rawArgv(0) should be fine here (these would be even better, but that can wait…)


val importPprintOnlyProject = TestInputs(
Seq(
os.rel / "simple.sc" -> s"import $$ivy.`com.lihaoyi::pprint:${Constants.pprintVersion}`"
)
)

test("setup-ide should have only absolute path if relative one was specified") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Weird, I thought I had answered this in an earlier review, but I can't see my answers here… Anyway, that was a good point ^^)

@MarcinAman MarcinAman force-pushed the setup-ide-before-all branch 5 times, most recently from 050e568 to dd566d8 Compare October 13, 2021 14:03
@@ -125,6 +126,17 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
expect(expectedPrefixes.exists(uri.startsWith))
}

def readBspConfig(root: os.Path, f: (Details) => Unit): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT Why not just returning the Details? And let the tests below do whatever they want with them?

@MarcinAman MarcinAman force-pushed the setup-ide-before-all branch 3 times, most recently from 305a3fb to 9e9262b Compare October 14, 2021 14:46
MarcinAman and others added 9 commits October 14, 2021 16:49
Co-authored-by: Alexandre Archambault <alexarchambault@users.noreply.github.com>

Co-authored-by: Alexandre Archambault <alexarchambault@users.noreply.github.com>
Co-authored-by: Alexandre Archambault <alexarchambault@users.noreply.github.com>
…stDefinitions.scala

Co-authored-by: Alexandre Archambault <alexarchambault@users.noreply.github.com>
@alexarchambault
Copy link
Contributor

alexarchambault commented Oct 14, 2021

Just pushed a NIT commit, with mostly minor syntax changes or dummy refactorings. Otherwise, LGTM.

And don't re-parse the input arguments, just use what's in the Inputs
instance.
@alexarchambault
Copy link
Contributor

CI is green 🎉

@alexarchambault alexarchambault merged commit 5cd81f5 into VirtusLab:master Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants