From 4a64a06023c1db5b894713b8938404104f433bb2 Mon Sep 17 00:00:00 2001 From: godenji Date: Thu, 12 Oct 2017 11:33:11 -0400 Subject: [PATCH] add scripted tests for opt-in base directory sources --- .../.scalariform.conf | 0 .../build.sbt | 15 ++++++++++ .../project/plugins.sbt | 13 +++++++++ .../sample/formatted.scala | 16 ++++++++++ .../sample/unformatted.scala | 14 +++++++++ .../test | 7 +++++ .../.scalariform.conf | 29 +++++++++++++++++++ .../build.sbt | 2 ++ .../project/plugins.sbt | 13 +++++++++ .../sample/formatted.scala | 16 ++++++++++ .../sample/unformatted.scala | 14 +++++++++ .../test | 7 +++++ 12 files changed, 146 insertions(+) create mode 100644 src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/.scalariform.conf create mode 100644 src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/build.sbt create mode 100644 src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/project/plugins.sbt create mode 100644 src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/formatted.scala create mode 100644 src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/unformatted.scala create mode 100644 src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/test create mode 100644 src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/.scalariform.conf create mode 100644 src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/build.sbt create mode 100644 src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/project/plugins.sbt create mode 100644 src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/formatted.scala create mode 100644 src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/unformatted.scala create mode 100644 src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/test diff --git a/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/.scalariform.conf b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/.scalariform.conf new file mode 100644 index 0000000..e69de29 diff --git a/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/build.sbt b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/build.sbt new file mode 100644 index 0000000..6487cb5 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/build.sbt @@ -0,0 +1,15 @@ +import scalariform.formatter.preferences._ +import com.typesafe.sbt.SbtScalariform.ScalariformKeys + +name := "test" +version := "0.1" + +scalariformWithBaseDirectory := true + +ScalariformKeys.preferences := ScalariformKeys.preferences.value + .setPreference(AlignArguments, true) + .setPreference(AlignSingleLineCaseStatements, true) + .setPreference(AlignSingleLineCaseStatements.MaxArrowIndent, 20) + .setPreference(CompactControlReadability, true) + .setPreference(DanglingCloseParenthesis, Force) + .setPreference(SpacesAroundMultiImports, false) diff --git a/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/project/plugins.sbt b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/project/plugins.sbt new file mode 100644 index 0000000..ba0d95e --- /dev/null +++ b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/project/plugins.sbt @@ -0,0 +1,13 @@ +sys.props.get("sbt-assembly.version") match { + case Some(x) => addSbtPlugin("com.eed3si9n" % "sbt-assembly" % x) + case _ => sys.error( + "'sbt-assembly.version' property not defined! (add it to scriptedLaunchOpts -D)" + ) +} + +sys.props.get("sbt-scalariform.version") match { + case Some(x) => addSbtPlugin("org.scalariform" % "sbt-scalariform" % x) + case _ => sys.error( + "'sbt-scalariform.version' property not defined! (add it to scriptedLaunchOpts -D)" + ) +} diff --git a/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/formatted.scala b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/formatted.scala new file mode 100644 index 0000000..424a9d4 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/formatted.scala @@ -0,0 +1,16 @@ +object Foo { + def method( + string: String, + int: Int + ) = { + string match { + case "wibble" => 42 + case "foo" => 123 + case _ => 100 + } + } + method( + string = "hello", + int = 1 + ) +} diff --git a/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/unformatted.scala b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/unformatted.scala new file mode 100644 index 0000000..b897d64 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/sample/unformatted.scala @@ -0,0 +1,14 @@ +object Foo { + def method( + string: String, + int: Int) = { + string match { + case "wibble" => 42 + case "foo" => 123 + case _ => 100 + } + } + method( + string = "hello", + int = 1) +} diff --git a/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/test b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/test new file mode 100644 index 0000000..2818d75 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/build-prefs-with-base-directory-sources/test @@ -0,0 +1,7 @@ +$ copy-file sample/unformatted.scala target/A.scala + +-$ must-mirror sample/formatted.scala target/A.scala + +# autoformat on compile +> compile +$ must-mirror sample/formatted.scala target/A.scala diff --git a/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/.scalariform.conf b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/.scalariform.conf new file mode 100644 index 0000000..a6ddc8e --- /dev/null +++ b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/.scalariform.conf @@ -0,0 +1,29 @@ +withBaseDirectory=true +alignArguments=true +#alignParameters=false +alignSingleLineCaseStatements=true +alignSingleLineCaseStatements.maxArrowIndent=20 +compactControlReadability=true +#compactStringConcatenation=false +danglingCloseParenthesis=Force +#doubleIndentClassDeclaration=false +#doubleIndentConstructorArguments=false +#doubleIndentMethodDeclaration=false +#firstArgumentOnNewline=Force +#firstParameterOnNewline=Force +#formatXml=true +#indentLocalDefs=false +#indentPackageBlocks=true +#indentSpaces=2 +#indentWithTabs=false +#multilineScaladocCommentsStartOnFirstLine=false +#newlineAtEndOfFile=false +#placeScaladocAsterisksBeneathSecondAsterisk=false +#preserveSpaceBeforeArguments=false +#rewriteArrowSymbols=false +#spaceBeforeColon=false +#spaceBeforeContextColon=false +#spaceInsideBrackets=false +#spaceInsideParentheses=false +spacesAroundMultiImports=false +#spacesWithinPatternBinders=true diff --git a/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/build.sbt b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/build.sbt new file mode 100644 index 0000000..8fd86b9 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/build.sbt @@ -0,0 +1,2 @@ +name := "test" +version := "0.1" diff --git a/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/project/plugins.sbt b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/project/plugins.sbt new file mode 100644 index 0000000..ba0d95e --- /dev/null +++ b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/project/plugins.sbt @@ -0,0 +1,13 @@ +sys.props.get("sbt-assembly.version") match { + case Some(x) => addSbtPlugin("com.eed3si9n" % "sbt-assembly" % x) + case _ => sys.error( + "'sbt-assembly.version' property not defined! (add it to scriptedLaunchOpts -D)" + ) +} + +sys.props.get("sbt-scalariform.version") match { + case Some(x) => addSbtPlugin("org.scalariform" % "sbt-scalariform" % x) + case _ => sys.error( + "'sbt-scalariform.version' property not defined! (add it to scriptedLaunchOpts -D)" + ) +} diff --git a/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/formatted.scala b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/formatted.scala new file mode 100644 index 0000000..424a9d4 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/formatted.scala @@ -0,0 +1,16 @@ +object Foo { + def method( + string: String, + int: Int + ) = { + string match { + case "wibble" => 42 + case "foo" => 123 + case _ => 100 + } + } + method( + string = "hello", + int = 1 + ) +} diff --git a/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/unformatted.scala b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/unformatted.scala new file mode 100644 index 0000000..b897d64 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/sample/unformatted.scala @@ -0,0 +1,14 @@ +object Foo { + def method( + string: String, + int: Int) = { + string match { + case "wibble" => 42 + case "foo" => 123 + case _ => 100 + } + } + method( + string = "hello", + int = 1) +} diff --git a/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/test b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/test new file mode 100644 index 0000000..2818d75 --- /dev/null +++ b/src/sbt-test/sbt-scalariform/file-prefs-with-base-directory-sources/test @@ -0,0 +1,7 @@ +$ copy-file sample/unformatted.scala target/A.scala + +-$ must-mirror sample/formatted.scala target/A.scala + +# autoformat on compile +> compile +$ must-mirror sample/formatted.scala target/A.scala