33
44package software.aws.toolkits.jetbrains.core.credentials.profiles
55
6- import com.intellij.openapi.Disposable
76import com.intellij.openapi.util.Disposer
87import com.intellij.openapi.util.Ref
98import com.intellij.openapi.vfs.LocalFileSystem
@@ -13,6 +12,7 @@ import com.intellij.openapi.vfs.newvfs.RefreshQueue
1312import com.intellij.testFramework.ApplicationRule
1413import com.intellij.testFramework.DisposableRule
1514import org.assertj.core.api.Assertions.assertThat
15+ import org.junit.AssumptionViolatedException
1616import org.junit.Before
1717import org.junit.ClassRule
1818import org.junit.Rule
@@ -21,6 +21,7 @@ import org.junit.rules.TemporaryFolder
2121import software.aws.toolkits.core.rules.SystemPropertyHelper
2222import software.aws.toolkits.jetbrains.utils.spinUntil
2323import java.io.File
24+ import java.io.IOException
2425import java.time.Duration
2526import java.util.concurrent.CountDownLatch
2627import java.util.concurrent.TimeUnit
@@ -56,6 +57,18 @@ class ProfileWatcherTest {
5657
5758 System .getProperties().setProperty(" aws.configFile" , profileFile.absolutePath)
5859 System .getProperties().setProperty(" aws.sharedCredentialsFile" , credentialsFile.absolutePath)
60+
61+ try {
62+ assertFileChange {
63+ profileFile.writeText(" Test" )
64+ }
65+ } catch (e: Exception ) {
66+ if (e.cause is IOException ) {
67+ throw AssumptionViolatedException (" native file watcher is not executable; possibly an issue with intellij-platform-gradle-plugin" , e)
68+ }
69+
70+ throw e
71+ }
5972 }
6073
6174 @Test
@@ -106,15 +119,14 @@ class ProfileWatcherTest {
106119 private fun assertFileChange (block : () -> Unit ) {
107120 val fileWatcher = (LocalFileSystem .getInstance() as LocalFileSystemImpl ).fileWatcher
108121 Disposer .register(
109- disposableRule.disposable,
110- Disposable {
111- fileWatcher.shutdown()
122+ disposableRule.disposable
123+ ) {
124+ fileWatcher.shutdown()
112125
113- spinUntil(Duration .ofSeconds(10 )) {
114- ! fileWatcher.isOperational
115- }
126+ spinUntil(Duration .ofSeconds(10 )) {
127+ ! fileWatcher.isOperational
116128 }
117- )
129+ }
118130
119131 val watcherTriggered = CountDownLatch (1 )
120132 fileWatcher.startup {
0 commit comments