Skip to content
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

AbstractScriptFileWatcher malfunction on Windows #3214

Closed
wborn opened this issue Dec 11, 2022 · 4 comments · Fixed by #3216
Closed

AbstractScriptFileWatcher malfunction on Windows #3214

wborn opened this issue Dec 11, 2022 · 4 comments · Fixed by #3216
Assignees
Labels
bug An unexpected problem or unintended behavior of the Core critical

Comments

@wborn
Copy link
Member

wborn commented Dec 11, 2022

I saw this test failing in a GHA Windows build: https://github.com/wborn/openhab-core/actions/runs/3668681734/jobs/6201979819
Perhaps it is related to the #3168 changes.

[ERROR] Tests run: 14, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 18.383 s <<< FAILURE! - in org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcherTest
[ERROR] org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcherTest.testDirectoryRemoved  Time elapsed: 10.701 s  <<< FAILURE!
Wanted but not invoked:
scriptEngineManagerMock.removeEngine(
    "file:/C:/Users/RUNNER~1/AppData/Local/Temp/junit9061750780238590199/dir/script.js"
);
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcherTest.testDirectoryRemoved(AbstractScriptFileWatcherTest.java:428)

However, there were exactly 7 interactions with this mock:
scriptEngineManagerMock.addFactoryChangeListener(
    org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcherTest$1@2d195ee4
);
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.<init>(AbstractScriptFileWatcher.java:93)

scriptEngineManagerMock.isSupported("js");
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$5(AbstractScriptFileWatcher.java:247)

scriptEngineManagerMock.createScriptEngine(
    "js",
    "file:/C:/Users/RUNNER~1/AppData/Local/Temp/junit9061750780238590199/dir/script.js"
);
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:272)

scriptEngineManagerMock.loadScript(
    null,
    java.io.InputStreamReader@3028e50e
);
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:276)

scriptEngineManagerMock.isSupported("js");
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$5(AbstractScriptFileWatcher.java:247)

scriptEngineManagerMock.createScriptEngine(
    "js",
    "file:/C:/Users/RUNNER~1/AppData/Local/Temp/junit9061750780238590199/dir/script2.js"
);
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:272)

scriptEngineManagerMock.loadScript(
    null,
    java.io.InputStreamReader@5560bcdf
);
-> at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:276)


	at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcherTest.testDirectoryRemoved(AbstractScriptFileWatcherTest.java:428)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutInvocation.proceed(TimeoutInvocation.java:46)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
@wborn wborn added the test label Dec 11, 2022
@J-N-K
Copy link
Member

J-N-K commented Dec 11, 2022

It's more likely related to #3185 and also critical as it'll break for users also in the real-life. I assume it is due to this code:

                                String prefix = file + File.separator;
                                var toRemove = loaded.stream()
                                        .filter(f -> f.getScriptFileURL().getFile().startsWith(prefix))
                                        .collect(Collectors.toList());
                                toRemove.forEach(this::removeFile);

@J-N-K J-N-K added bug An unexpected problem or unintended behavior of the Core critical labels Dec 11, 2022
@J-N-K
Copy link
Member

J-N-K commented Dec 11, 2022

Can we add windows GHA builds to the repo? We have seen that more than once.

@wborn
Copy link
Member Author

wborn commented Dec 11, 2022

I'm doing some testing with macOS/Windows so we can add them in the future. The bash scripts we use in the GHA CI builds don't work well on other OS-es. So I've already ported most of the bash code to Java. That way it won't really matter what OS is used. 🙂

@J-N-K
Copy link
Member

J-N-K commented Dec 11, 2022

I'll have a look at this one, but I can't promise I get is fixed until this afternoon.

@J-N-K J-N-K self-assigned this Dec 11, 2022
@J-N-K J-N-K changed the title AbstractScriptFileWatcherTest unstable AbstractScriptFileWatcher malfunction on Windows Dec 11, 2022
@J-N-K J-N-K removed the test label Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core critical
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants