-
-
Notifications
You must be signed in to change notification settings - Fork 422
Zinc based testQuick command
#4787
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
integration/feature/test-quick/resources/app/src/MyNumber.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package app | ||
|
|
||
| import lib.* | ||
|
|
||
| final case class MyNumber(val value: Int) | ||
|
|
||
| object MyNumber { | ||
|
|
||
| given gCombinator: Combinator[MyNumber] = new Combinator[MyNumber] { | ||
| def combine(a: MyNumber, b: MyNumber): MyNumber = MyNumber(a.value + b.value) | ||
| } | ||
|
|
||
| given gDefaultValue: DefaultValue[MyNumber] = new DefaultValue[MyNumber] { | ||
| def defaultValue: MyNumber = MyNumber(0) | ||
| } | ||
|
|
||
| def combine(a: MyNumber, b: MyNumber, c: MyNumber): MyNumber = { | ||
| val temp = gCombinator.combine(a, b) | ||
| gCombinator.combine(temp, c) | ||
| } | ||
|
|
||
| def defaultValue: MyNumber = gDefaultValue.defaultValue | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
integration/feature/test-quick/resources/app/src/MyString.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package app | ||
|
|
||
| import lib.* | ||
|
|
||
| final case class MyString(val value: String) | ||
|
|
||
| object MyString { | ||
|
|
||
| given gCombinator: Combinator[MyString] = new Combinator[MyString] { | ||
| def combine(a: MyString, b: MyString): MyString = MyString(a.value + b.value) | ||
| } | ||
|
|
||
| given gDefaultValue: DefaultValue[MyString] = new DefaultValue[MyString] { | ||
| def defaultValue: MyString = MyString("") | ||
| } | ||
|
|
||
| def combine(a: MyString, b: MyString, c: MyString): MyString = { | ||
| val temp = gCombinator.combine(a, b) | ||
| gCombinator.combine(temp, c) | ||
| } | ||
|
|
||
| def defaultValue: MyString = gDefaultValue.defaultValue | ||
|
|
||
| } |
16 changes: 16 additions & 0 deletions
16
integration/feature/test-quick/resources/app/test/src/MyNumberCombinatorTests.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package app | ||
|
|
||
| import utest.* | ||
| import app.MyNumber | ||
|
|
||
| object MyNumberCombinatorTests extends TestSuite { | ||
| def tests = Tests { | ||
| test("simple") { | ||
| val a = MyNumber(1) | ||
| val b = MyNumber(2) | ||
| val c = MyNumber(3) | ||
| val result = MyNumber.combine(a, b, c) | ||
| assert(result == MyNumber(6)) | ||
| } | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
integration/feature/test-quick/resources/app/test/src/MyNumberDefaultValueTests.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package app | ||
|
|
||
| import utest.* | ||
| import app.MyNumber | ||
|
|
||
| object MyNumberDefaultValueTests extends TestSuite { | ||
| def tests = Tests { | ||
| test("simple") { | ||
| val result = MyNumber.defaultValue | ||
| assert(result == MyNumber(0)) | ||
| } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
integration/feature/test-quick/resources/app/test/src/MyStringCombinatorTests.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package app | ||
|
|
||
| import utest.* | ||
| import app.MyString | ||
|
|
||
| object MyStringCombinatorTests extends TestSuite { | ||
| def tests = Tests { | ||
| test("simple") { | ||
| val a = MyString("a") | ||
| val b = MyString("b") | ||
| val c = MyString("c") | ||
| val result = MyString.combine(a, b, c) | ||
| assert(result == MyString("abc")) | ||
| } | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
integration/feature/test-quick/resources/app/test/src/MyStringDefaultValueTests.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package app | ||
|
|
||
| import utest.* | ||
| import app.MyString | ||
|
|
||
| object MyStringDefaultValueTests extends TestSuite { | ||
| def tests = Tests { | ||
| test("simple") { | ||
| val result = MyString.defaultValue | ||
| assert(result == MyString("")) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package build | ||
|
|
||
| import mill._, scalalib._ | ||
|
|
||
| object lib extends ScalaModule { | ||
| def scalaVersion = "3.3.1" | ||
| } | ||
|
|
||
| object app extends ScalaModule { | ||
| def scalaVersion = "3.3.1" | ||
| def moduleDeps = Seq(lib) | ||
|
|
||
| object test extends ScalaTests { | ||
| def ivyDeps = Seq(ivy"com.lihaoyi::utest:0.8.5") | ||
| def testFramework = "utest.runner.Framework" | ||
| def moduleDeps = Seq(app) | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
integration/feature/test-quick/resources/lib/src/Combinator.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package lib | ||
|
|
||
| trait Combinator[T] { | ||
| def combine(a: T, b: T): T | ||
| } |
5 changes: 5 additions & 0 deletions
5
integration/feature/test-quick/resources/lib/src/DefaultValue.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package lib | ||
|
|
||
| trait DefaultValue[T] { | ||
| def defaultValue: T | ||
| } |
104 changes: 104 additions & 0 deletions
104
integration/feature/test-quick/src/TestQuickTests.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package mill.integration | ||
|
|
||
| import mill.testkit.UtestIntegrationTestSuite | ||
|
|
||
| import utest._ | ||
|
|
||
| object TestQuickTests extends UtestIntegrationTestSuite { | ||
| val tests: Tests = Tests { | ||
| test("update app file") - integrationTest { tester => | ||
| import tester._ | ||
|
|
||
| // First run, all tests should run | ||
| val firstRun = eval("app.test.testQuick") | ||
| val firstRunOutLines = firstRun.out.linesIterator.toSeq | ||
| Seq( | ||
| "app.MyNumberCombinatorTests.simple", | ||
| "app.MyStringCombinatorTests.simple", | ||
| "app.MyStringDefaultValueTests.simple", | ||
| "app.MyNumberDefaultValueTests.simple", | ||
| ).foreach { expectedLines => | ||
| val exists = firstRunOutLines.exists(_.contains(expectedLines)) | ||
| assert(exists) | ||
| } | ||
|
|
||
| // Second run, nothing should run because we're not changing anything | ||
| val secondRun = eval("app.test.testQuick") | ||
| assert(secondRun.out.isEmpty) | ||
|
|
||
| // Third run, MyNumber.scala changed, so MyNumberDefaultValueTests & MyNumberCombinatorTests should run | ||
| modifyFile(workspacePath / "app" / "src" / "MyNumber.scala", _.replace("def defaultValue: MyNumber = MyNumber(0)", "def defaultValue: MyNumber = MyNumber(1)")) | ||
| val thirdRun = eval("app.test.testQuick") | ||
| val thirdRunOutLines = thirdRun.out.linesIterator.toSeq | ||
| Seq( | ||
| "app.MyNumberCombinatorTests.simple", | ||
| "app.MyNumberDefaultValueTests.simple", | ||
| ).foreach { expectedLines => | ||
| val exists = thirdRunOutLines.exists(_.contains(expectedLines)) | ||
| assert(exists) | ||
| } | ||
|
|
||
| // Fourth run, MyNumberDefaultValueTests was failed, so it should run again | ||
| val fourthRun = eval("app.test.testQuick") | ||
| val fourthRunOutLines = fourthRun.out.linesIterator.toSeq | ||
| Seq( | ||
| "app.MyNumberDefaultValueTests.simple", | ||
| ).foreach { expectedLines => | ||
| val exists = fourthRunOutLines.exists(_.contains(expectedLines)) | ||
| assert(exists) | ||
| } | ||
|
|
||
| // Fifth run, MyNumberDefaultValueTests was fixed, so it should run again | ||
| modifyFile(workspacePath / "app" / "test" / "src" / "MyNumberDefaultValueTests.scala", _.replace("assert(result == MyNumber(0))", "assert(result == MyNumber(1))")) | ||
| val fifthRun = eval("app.test.testQuick") | ||
| val fifthRunOutLines = fifthRun.out.linesIterator.toSeq | ||
| Seq( | ||
| "app.MyNumberDefaultValueTests.simple", | ||
| ).foreach { expectedLines => | ||
| val exists = fifthRunOutLines.exists(_.contains(expectedLines)) | ||
| assert(exists) | ||
| } | ||
|
|
||
| // Sixth run, nothing should run because we're not changing anything | ||
| val sixthRun = eval("app.test.testQuick") | ||
| assert(sixthRun.out.isEmpty) | ||
| } | ||
| test("update lib file") - integrationTest { tester => | ||
| import tester._ | ||
|
|
||
| // First run, all tests should run | ||
| val firstRun = eval("app.test.testQuick") | ||
| val firstRunOutLines = firstRun.out.linesIterator.toSeq | ||
| Seq( | ||
| "app.MyNumberCombinatorTests.simple", | ||
| "app.MyStringCombinatorTests.simple", | ||
| "app.MyStringDefaultValueTests.simple", | ||
| "app.MyNumberDefaultValueTests.simple", | ||
| ).foreach { expectedLines => | ||
| val exists = firstRunOutLines.exists(_.contains(expectedLines)) | ||
| assert(exists) | ||
| } | ||
|
|
||
| // Second run, nothing should run because we're not changing anything | ||
| val secondRun = eval("app.test.testQuick") | ||
| assert(secondRun.out.isEmpty) | ||
|
|
||
| // Third run, Combinator.scala changed, so MyNumberCombinatorTests & MyStringCombinatorTests should run | ||
| modifyFile(workspacePath / "lib" / "src" / "Combinator.scala", _.replace("def combine(a: T, b: T): T", "def combine(b: T, a: T): T")) | ||
| val thirdRun = eval("app.test.testQuick") | ||
| val thirdRunOutLines = thirdRun.out.linesIterator.toSeq | ||
| Seq( | ||
| "app.MyNumberCombinatorTests.simple", | ||
| "app.MyStringCombinatorTests.simple", | ||
| ).foreach { expectedLines => | ||
| val exists = thirdRunOutLines.exists(_.contains(expectedLines)) | ||
| assert(exists) | ||
| } | ||
|
|
||
| // Fourth run, nothing should run because we're not changing anything | ||
| val fourthRun = eval("app.test.testQuick") | ||
| assert(fourthRun.out.isEmpty) | ||
| } | ||
| } | ||
| } | ||
|
|
||
26 changes: 26 additions & 0 deletions
26
scalalib/api/src/mill/scalalib/api/TransitiveSourceStampResults.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package mill.scalalib.api | ||
|
|
||
| final case class TransitiveSourceStampResults( | ||
| currentStamps: Map[String, String], | ||
| previousStamps: Option[Map[String, String]] = None | ||
| ) { | ||
| lazy val changedSources: Set[String] = { | ||
| previousStamps match { | ||
| case Some(prevStamps) => | ||
| currentStamps.view | ||
| .flatMap { (source, stamp) => | ||
| prevStamps.get(source) match { | ||
| case None => Some(source) // new source | ||
| case Some(prevStamp) => Option.when(stamp != prevStamp)(source) // changed source | ||
| } | ||
| } | ||
| .toSet | ||
| case None => currentStamps.keySet | ||
| } | ||
| } | ||
| } | ||
|
|
||
| object TransitiveSourceStampResults { | ||
| implicit val jsonFormatter: upickle.default.ReadWriter[TransitiveSourceStampResults] = | ||
| upickle.default.macroRW | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be the main different between this
Zincbased approach and the method call approach. The method call approach is expected to only trigger theMyNumberDefaultValueTeststest, not theMyNumberCombinatorTeststest