From 8cd543522596572d1f1c690ae7b9ae37fd97d884 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 28 Oct 2019 14:12:29 +0800 Subject: [PATCH] Bump oslib to 0.4.2 (#1015) * bump oslib to 0.4.0 * fix * fix * oslib 0.4.2 --- .../src/main/scala/ammonite/interp/Interpreter.scala | 7 +++++-- .../src/main/scala/ammonite/runtime/Storage.scala | 12 ++++++------ amm/src/test/scala/ammonite/main/MainTests.scala | 4 ++-- build.sc | 2 +- .../test/scala/ammonite/integration/BasicTests.scala | 5 ++++- .../test/scala/ammonite/integration/TestUtils.scala | 5 ++++- ops/src/main/scala-2.12/ammonite/ops/LsSeq.scala | 2 +- ops/src/main/scala-2.13/ammonite/ops/LsSeq.scala | 2 +- ops/src/main/scala/ammonite/ops/package.scala | 5 +++-- .../test/scala/test/ammonite/ops/ExampleTests.scala | 6 ------ readme/Ops.scalatex | 2 +- .../src/test/scala/ammonite/shell/SessionTests.scala | 8 ++++---- 12 files changed, 32 insertions(+), 28 deletions(-) diff --git a/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala b/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala index 65fd98de3..8d368ce57 100644 --- a/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala +++ b/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala @@ -362,7 +362,10 @@ class Interpreter(val printer: Printer, ) - val cachedScriptData = storage.classFilesListLoad(codeSource.filePathPrefix, tag) + val cachedScriptData = storage.classFilesListLoad( + os.sub / codeSource.filePathPrefix, + tag + ) // Lazy, because we may not always need this if the script is already cached @@ -398,7 +401,7 @@ class Interpreter(val printer: Printer, ) } yield { storage.classFilesListSave( - codeSource.filePathPrefix, + os.sub / codeSource.filePathPrefix, metadata.blockInfo, tag ) diff --git a/amm/runtime/src/main/scala/ammonite/runtime/Storage.scala b/amm/runtime/src/main/scala/ammonite/runtime/Storage.scala index 5e6330822..136d0dcc2 100644 --- a/amm/runtime/src/main/scala/ammonite/runtime/Storage.scala +++ b/amm/runtime/src/main/scala/ammonite/runtime/Storage.scala @@ -26,10 +26,10 @@ trait Storage{ def compileCacheSave(path: String, tag: Tag, data: Storage.CompileCache): Unit def compileCacheLoad(path: String, tag: Tag): Option[Storage.CompileCache] - def classFilesListSave(filePathPrefix: os.RelPath, + def classFilesListSave(filePathPrefix: os.SubPath, perBlockMetadata: Seq[ScriptOutput.BlockMetadata], tag: Tag): Unit - def classFilesListLoad(filePathPrefix: os.RelPath, tag: Tag): Option[ScriptOutput] + def classFilesListLoad(filePathPrefix: os.SubPath, tag: Tag): Option[ScriptOutput] def getSessionId: Long } @@ -160,14 +160,14 @@ object Storage{ } yield data } - def classFilesListSave(filePathPrefix: os.RelPath, + def classFilesListSave(filePathPrefix: os.SubPath, perBlockMetadata: Seq[ScriptOutput.BlockMetadata], tag: Tag): Unit = { classFilesListcache(filePathPrefix.toString) = (tag, perBlockMetadata) } - def classFilesListLoad(filePathPrefix: os.RelPath, + def classFilesListLoad(filePathPrefix: os.SubPath, cacheTag: Tag): Option[ScriptOutput] = { classFilesListcache.get(filePathPrefix.toString) match{ @@ -218,7 +218,7 @@ object Storage{ } - def classFilesListSave(filePathPrefix: os.RelPath, + def classFilesListSave(filePathPrefix: os.SubPath, perBlockMetadata: Seq[ScriptOutput.BlockMetadata], tag: Tag): Unit = { @@ -246,7 +246,7 @@ object Storage{ catch{ case e: Throwable => None } } - def classFilesListLoad(filePathPrefix: os.RelPath, + def classFilesListLoad(filePathPrefix: os.SubPath, tag: Tag): Option[ScriptOutput] = { val codeCacheDir = diff --git a/amm/src/test/scala/ammonite/main/MainTests.scala b/amm/src/test/scala/ammonite/main/MainTests.scala index c60aa42c2..fc22a6a58 100755 --- a/amm/src/test/scala/ammonite/main/MainTests.scala +++ b/amm/src/test/scala/ammonite/main/MainTests.scala @@ -10,8 +10,8 @@ import utest._ * and the associated error behavior if the caller messes up. */ object MainTests extends TestSuite{ - def exec(p: os.RelPath, args: String*) = - new InProcessMainMethodRunner(os.rel / 'mains/p, Nil, args) + def exec(p: String, args: String*) = + new InProcessMainMethodRunner(os.rel / 'mains / p, Nil, args) def stripInvisibleMargin(s: String): String = { val lines = Predef.augmentString(s).lines.toArray diff --git a/build.sc b/build.sc index 9a48a956a..88937ff7d 100644 --- a/build.sc +++ b/build.sc @@ -132,7 +132,7 @@ trait AmmDependenciesResourceFileModule extends JavaModule{ object ops extends Cross[OpsModule](binCrossScalaVersions:_*) class OpsModule(val crossScalaVersion: String) extends AmmModule{ def ivyDeps = Agg( - ivy"com.lihaoyi::os-lib:0.3.0", + ivy"com.lihaoyi::os-lib:0.4.2", ivy"org.scala-lang.modules::scala-collection-compat:2.1.2" ) def scalacOptions = super.scalacOptions().filter(!_.contains("acyclic")) diff --git a/integration/src/test/scala/ammonite/integration/BasicTests.scala b/integration/src/test/scala/ammonite/integration/BasicTests.scala index cf504defd..495a55bad 100644 --- a/integration/src/test/scala/ammonite/integration/BasicTests.scala +++ b/integration/src/test/scala/ammonite/integration/BasicTests.scala @@ -26,7 +26,10 @@ object BasicTests extends TestSuite{ "-h", home, replStandaloneResources/name - ).call(env = Map("JAVA_OPTS" -> "-verbose:class")) + ).call( + env = Map("JAVA_OPTS" -> "-verbose:class"), + stderr = os.Pipe + ) test("hello"){ val evaled = exec(os.rel / 'basic/"Hello.sc") diff --git a/integration/src/test/scala/ammonite/integration/TestUtils.scala b/integration/src/test/scala/ammonite/integration/TestUtils.scala index 45405e9b6..287f60200 100644 --- a/integration/src/test/scala/ammonite/integration/TestUtils.scala +++ b/integration/src/test/scala/ammonite/integration/TestUtils.scala @@ -33,7 +33,10 @@ object TestUtils { home, replStandaloneResources / name, args - ).call(env = Map("JAVA_OPTS" -> null)) + ).call( + env = Map("JAVA_OPTS" -> null), + stderr = os.Pipe + ) } def exec(name: RelPath, args: String*) = execBase(name, Nil, tmp.dir(), args, thin = true) diff --git a/ops/src/main/scala-2.12/ammonite/ops/LsSeq.scala b/ops/src/main/scala-2.12/ammonite/ops/LsSeq.scala index 3ca250890..57357bf30 100644 --- a/ops/src/main/scala-2.12/ammonite/ops/LsSeq.scala +++ b/ops/src/main/scala-2.12/ammonite/ops/LsSeq.scala @@ -7,5 +7,5 @@ package ammonite.ops case class LsSeq(base: Path, listed: RelPath*) extends Seq[Path]{ def length = listed.length def apply(idx: Int) = base/listed.apply(idx) - def iterator = listed.iterator.map(base/) + def iterator = listed.iterator.map(base / _) } diff --git a/ops/src/main/scala-2.13/ammonite/ops/LsSeq.scala b/ops/src/main/scala-2.13/ammonite/ops/LsSeq.scala index 22b2dd4b5..884bb7ade 100644 --- a/ops/src/main/scala-2.13/ammonite/ops/LsSeq.scala +++ b/ops/src/main/scala-2.13/ammonite/ops/LsSeq.scala @@ -9,7 +9,7 @@ import scala.collection.generic.IsIterable case class LsSeq(base: Path, listed: RelPath*) extends Seq[Path]{ def length = listed.length def apply(idx: Int) = base/listed.apply(idx) - def iterator = listed.iterator.map(base/) + def iterator = listed.iterator.map(base / _) } object LsSeq { diff --git a/ops/src/main/scala/ammonite/ops/package.scala b/ops/src/main/scala/ammonite/ops/package.scala index dcb9484e7..39cc934e6 100644 --- a/ops/src/main/scala/ammonite/ops/package.scala +++ b/ops/src/main/scala/ammonite/ops/package.scala @@ -31,7 +31,7 @@ package object ops extends Extensions { object stat extends Function1[Path, os.StatInfo]{ def apply(s: Path, followLinks: Boolean = true) = os.stat(s, followLinks) def apply(s: Path) = os.stat(s) - val full = os.stat.full + val posix = os.stat.posix } implicit def SymPath(s: Symbol): RelPath = StringPath(s.name) implicit def StringPath(s: String): RelPath = { @@ -114,7 +114,8 @@ package object ops extends Extensions { * normally access through [[stat]]-ing it by [[stat]]-ing the file for you * when necessary. */ - implicit def fileData(p: Path): os.FullStatInfo = stat.full(p) + implicit def statFileData(p: Path): os.StatInfo = stat(p) + implicit def posixFileData(p: Path): os.PosixStatInfo = stat.posix(p) /** * Used to spawn a subprocess interactively; any output gets printed to the diff --git a/ops/src/test/scala/test/ammonite/ops/ExampleTests.scala b/ops/src/test/scala/test/ammonite/ops/ExampleTests.scala index 76282f30b..e1478c31f 100644 --- a/ops/src/test/scala/test/ammonite/ops/ExampleTests.scala +++ b/ops/src/test/scala/test/ammonite/ops/ExampleTests.scala @@ -102,12 +102,6 @@ object ExampleTests extends TestSuite{ // Ammonite provides an implicit conversion from `Path` to // `stat`, so you can use these attributes directly (wd/"file1.txt").size ==> 20 - - // You can also use `stat.full` which provides more information - val fullInfo = stat.full(wd/"file1.txt") - fullInfo.ctime: FileTime - fullInfo.atime: FileTime - fullInfo.group: GroupPrincipal () } test("longExample"){ diff --git a/readme/Ops.scalatex b/readme/Ops.scalatex index 9d830a3c1..83de41098 100644 --- a/readme/Ops.scalatex +++ b/readme/Ops.scalatex @@ -194,7 +194,7 @@ @li @hl.scala{stat! path}, @a("[doc]", href := (docBase+ "stat$")) @li - @hl.scala{stat.full! path}, @a("[doc]", href := (docBase+ "stat$$full$")) + @hl.scala{stat.posix! path}, @a("[doc]", href := (docBase+ "stat$$posix$")) @li @hl.scala{ln(src, dest)}, @a("[doc]", href := (docBase+ "ln$")) @li diff --git a/shell/src/test/scala/ammonite/shell/SessionTests.scala b/shell/src/test/scala/ammonite/shell/SessionTests.scala index 203e14146..ed9d76552 100644 --- a/shell/src/test/scala/ammonite/shell/SessionTests.scala +++ b/shell/src/test/scala/ammonite/shell/SessionTests.scala @@ -185,9 +185,9 @@ object SessionTests extends TestSuite{ @ assert(!stat('test132).isDir && !stat('test132).isSymLink && stat('test130).isDir) - @ assert(!stat.full('test132).isDir && !stat.full('test132).isSymLink) + @ assert(!stat('test132).isDir && !stat('test132).isSymLink) - @ assert(stat.full('test130).isDir) + @ assert(stat('test130).isDir) @ assert(ls.rec(wd).length == 5) @@ -217,11 +217,11 @@ object SessionTests extends TestSuite{ @ assert(!stat(t/'test132).isDir && !stat(t/'test132).isSymLink) - @ assert(!stat.full(t/'test132).isDir && !stat.full(t/'test132).isSymLink) + @ assert(!stat(t/'test132).isDir && !stat(t/'test132).isSymLink) @ assert(stat(t/'test130).isDir && stat(t, followLinks = false).isSymLink) - @ assert(stat.full(t/'test130).isDir && stat.full(t, followLinks = false).isSymLink) + @ assert(stat(t/'test130).isDir && stat(t, followLinks = false).isSymLink) @ rm! tmpdir """)