Skip to content

Commit

Permalink
Bump oslib to 0.4.2 (#1015)
Browse files Browse the repository at this point in the history
* bump oslib to 0.4.0

* fix

* fix

* oslib 0.4.2
  • Loading branch information
lihaoyi authored Oct 28, 2019
1 parent 71e4df4 commit 8cd5435
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 28 deletions.
7 changes: 5 additions & 2 deletions amm/interp/src/main/scala/ammonite/interp/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -398,7 +401,7 @@ class Interpreter(val printer: Printer,
)
} yield {
storage.classFilesListSave(
codeSource.filePathPrefix,
os.sub / codeSource.filePathPrefix,
metadata.blockInfo,
tag
)
Expand Down
12 changes: 6 additions & 6 deletions amm/runtime/src/main/scala/ammonite/runtime/Storage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -218,7 +218,7 @@ object Storage{
}


def classFilesListSave(filePathPrefix: os.RelPath,
def classFilesListSave(filePathPrefix: os.SubPath,
perBlockMetadata: Seq[ScriptOutput.BlockMetadata],
tag: Tag): Unit = {

Expand Down Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions amm/src/test/scala/ammonite/main/MainTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ops/src/main/scala-2.12/ammonite/ops/LsSeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 / _)
}
2 changes: 1 addition & 1 deletion ops/src/main/scala-2.13/ammonite/ops/LsSeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions ops/src/main/scala/ammonite/ops/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions ops/src/test/scala/test/ammonite/ops/ExampleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"){
Expand Down
2 changes: 1 addition & 1 deletion readme/Ops.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions shell/src/test/scala/ammonite/shell/SessionTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
""")
Expand Down

0 comments on commit 8cd5435

Please sign in to comment.