/* Ċ Ġ* ĠCopyright Ġ 2 0 1 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . Ġand ĠKotlin ĠProgramming ĠLanguage Ġcontributors . Ċ Ġ* ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe Ġlicense / LICENSE . txt Ġfile . Ċ Ġ*/ Ċ Ċ package Ġorg . jetbrains . kotlin . idea . script ing . gradle Ċ Ċ import Ġorg . jetbrains . kotlin . idea . core . script . Script Configuration Manager Ċ import Ġorg . jetbrains . kotlin . idea . script . Abstract Script Configuration Loading Test Ċ import Ġorg . jetbrains . kotlin . psi . Kt File Ċ import Ġorg . jetbrains . kotlin . test . JUnit 3 With Ide a Configuration Runner Ċ import Ġorg . jetbrains . plugins . gradle . util . Gradle Constants Ċ import Ġorg . junit . runner . RunWith Ċ import Ġjava . io . File Ċ Ċ @ RunWith ( JUnit 3 With Ide a Configuration Runner :: class ) Ċ class ĠGradle Script OutOf Project Test Ġ: ĠAbstract Script Configuration Loading Test () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠsetUp Test Project () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġroot Dir Ġ= Ġ" idea / testData / script / definition / loading / gradle /" ĊĊĠĠĠĠĠĠĠ Ġval Ġbuild Gradle K ts Ġ= ĠFile ( rootDir ). walk Top Down (). find Ġ{ Ġit . name Ġ== ĠGradle Constants . K OT LIN _ DSL _ SCRIPT _ NAME Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġerror (" Couldn 't Ġfind Ġmain Ġscript ") ĊĊĠĠĠĠĠĠĠ Ġconfigure Script File ( rootDir , Ġbuild Gradle K ts ) ĊĊĠĠĠĠĠĠĠ Ġtest Affected Gradle Project Files Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . te ar Down () ĊĊĠĠĠĠĠĠĠ Ġtest Affected Gradle Project Files Ġ= Ġfalse ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġloader For OutOf Project Scripts Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ ĠGradle Script Configuration Loader For OutOf Project Scripts ( project ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtest Manual Loading For Up ToDate () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Configuration ShouldBe Loaded Man ually () ĊĊĠĠĠĠĠĠĠ Ġscript Configuration Manager . force Reload Configuration ( my File . virtual File , Ġloader For OutOf Project Scripts ) ĊĊĠĠĠĠĠĠĠ Ġassert Configuration Was Loaded () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtest Manual Loading For OutOf Date () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Configuration ShouldBe Loaded Man ually () ĊĊĠĠĠĠĠĠĠ Ġmake Changes Inside Sections () ĊĊĠĠĠĠĠĠĠ Ġassert No Background Tasks () ĊĠĠĠĠĠĠĠ Ġassert No Loading () ĊĊĠĠĠĠĠĠĠ Ġscript Configuration Manager . force Reload Configuration ( my File . virtual File , Ġloader For OutOf Project Scripts ) ĊĊĠĠĠĠĠĠĠ Ġassert Configuration Was Loaded () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtest File Attributes For Manual Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Configuration ShouldBe Loaded Man ually () ĊĊĠĠĠĠĠĠĠ Ġscript Configuration Manager . force Reload Configuration ( my File . virtual File , Ġloader For OutOf Project Scripts ) ĊĊĠĠĠĠĠĠĠ Ġassert Configuration Was Loaded () ĊĊĠĠĠĠĠĠĠ ĠScript Configuration Manager . clear Caches ( project ) ĊĊĠĠĠĠĠĠĠ ĠassertNotNull ( getConfiguration ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtest No Notification After For Reload () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Configuration ShouldBe Loaded Man ually () ĊĊĠĠĠĠĠĠĠ Ġscript Configuration Manager . force Reload Configuration ( my File . virtual File , Ġloader For OutOf Project Scripts ) ĊĠĠĠĠĠĠĠ Ġassert Configuration Was Loaded () ĊĊĠĠĠĠĠĠĠ Ġmake Changes Inside Sections () ĊĊĠĠĠĠĠĠĠ Ġscript Configuration Manager . force Reload Configuration ( my File . virtual File , Ġloader For OutOf Project Scripts ) ĊĠĠĠĠĠĠĠ Ġassert Configuration Was Loaded () ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġmake Changes Inside Sections () Ġ{ ĊĠĠĠĠĠĠĠ Ġchange Contents ( my File . text . replace ( Gradle Script Inputs Watcher Test . inside Placeholder , Ġ" application "), Ġmy File ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġassert Configuration ShouldBe Loaded Man ually () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertNull ( getConfiguration ()) ĊĠĠĠĠĠĠĠ Ġassert And Do All Background Tasks () ĊĠĠĠĠĠĠĠ Ġassert No Loading () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġassert Configuration Was Loaded () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert And Do All Background Tasks () ĊĠĠĠĠĠĠĠ Ġassert Single Loading () ĊĠĠĠĠĠĠĠ Ġassert No Suggest ed Configuration () ĊĠĠĠĠĠĠĠ ĠassertNotNull ( getConfiguration ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Configuration () Ġ= ĊĠĠĠĠĠĠĠ Ġscript Configuration Manager . getConfiguration ( my File Ġas ĠK t File ) Ċ }