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

[Bug]: DemoDebug Local test failed #1242

Open
3 tasks done
Jaehwa-Noh opened this issue Mar 4, 2024 · 16 comments
Open
3 tasks done

[Bug]: DemoDebug Local test failed #1242

Jaehwa-Noh opened this issue Mar 4, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@Jaehwa-Noh
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • I have searched StackOverflow

What happened?

Run local tests on DemoDebug variant: ./gradlew testDemoDebug
has failed test on the barely fork the repository.

I entered the command in the Execute Gradle Task on android studio.
image

But the test does not success, see below.
image

Any thing I missed? or is this already known issue?

Relevant logcat output

Output is so long, I'd add partially.

java.lang.IllegalArgumentException: resource native/windows/x86_64/robolectric-nativeruntime.dll not found.

java.io.IOException: Unable to rename C:\Users\Jaehwa\AppData\Local\Temp\junit4146744981157378858\user_preferences_test.pb.tmp.This likely means that there are multiple instances of DataStore for this file. Ensure that you are only creating a single instance of datastore for this file.

14 tests completed, 4 failed
14 tests completed, 4 failed


        Caused by: java.io.IOException at NiaPreferencesDataSourceTest.kt:92

        Caused by: java.io.IOException at NiaPreferencesDataSourceTest.kt:74

        Caused by: java.io.IOException at NiaPreferencesDataSourceTest.kt:53

        Caused by: java.io.IOException at NiaPreferencesDataSourceTest.kt:92

        Caused by: java.io.IOException at NiaPreferencesDataSourceTest.kt:74

        Caused by: java.io.IOException at NiaPreferencesDataSourceTest.kt:53

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Jaehwa-Noh Jaehwa-Noh added the bug Something isn't working label Mar 4, 2024
@sanao1006
Copy link
Contributor

sanao1006 commented Mar 4, 2024

Are You a Windows OS User?
Now in Android screenshot test library uses Roborazzi. This library uses Robolectric NATIVE GraphicsMode internally, but this does not support Windows OS and seems to cause the following error

java.lang.IllegalArgumentException: resource native/windows/x86_64/robolectric-nativeruntime.dll not found.

So, the local screenshot tests would fail on Windows OS.
ref: robolectric/robolectric#8312

I am not sure of the exact cause of the problem with the DataStore, but I have encountered the same error, too.

@Jaehwa-Noh
Copy link
Contributor Author

Jaehwa-Noh commented Mar 4, 2024

Yes, I'm use a Windows OS.
Thank you, I didn't know Roborazzi doesn't support Windows OS.
You say, encountered same error with DataStore, it gives me relief.

@sanao1006
Copy link
Contributor

sanao1006 commented Mar 4, 2024

Roborazzi doesn't support Windows OS.

I think it would be correct to express that Roborazzi does not support Windows OS, but rather Robolectric NATIVE GraphicsMode does not support Windows OS!

@Jaehwa-Noh
Copy link
Contributor Author

Jaehwa-Noh commented Mar 4, 2024

Yes, I agree with that.

So, the local screenshot tests would fail on Windows OS.
ref: robolectric/robolectric#8312

I checked that word from yours link.

@SimonMarquis
Copy link
Contributor

The issue with Roborazzi and DataStore are two different issue.
For the DataStore issue, you can read more on this issue (especially the last comment with links):

@Jaehwa-Noh
Copy link
Contributor Author

Jaehwa-Noh commented Mar 4, 2024

From your Issues and relative links, I finally landed this page.
Might be the datastore problem will be solved when the next DataStore version release.
Thank you.

@SimonMarquis
Copy link
Contributor

Robolectric 4.11 adds support for the native runtime (native SQLite and graphics modes) on Windows.
https://github.com/robolectric/robolectric/releases/tag/robolectric-4.12

@JackEblan
Copy link

@SimonMarquis I recently tried to use Roborazzi in my app but it get stucked 😅 when I ran it on my machine. Maybe Roborazzi needs to update too or I'm the only one experiencing this.

- Windows 10
- Iguana

@SimonMarquis
Copy link
Contributor

SimonMarquis commented Mar 30, 2024

Unfortunately there still seems to be issues with windows runners...
Like this one:

java.nio.file.FileSystemException: C:\Users\RUNNER~1\AppData\Local\Temp\robolectric-nativeruntime12669726669700075741\fonts\CarroisGothicSC-Regular.ttf: The process cannot access the file because it is being used by another process

https://github.com/SimonMarquis/nowinandroid/actions/runs/8488861060/job/23258373077#step:13:1

@takahirom
Copy link
Contributor

I was unable to reproduce this issue in roborazzi repository.
Therefore, I attempted to use the nowinandroid repository and tried fixing it with ActivityScenario.close, but it seems to be ineffective.
I also reviewed the Robolectric repository and noticed that @hoisie addressed a similar issue last week.
robolectric/robolectric@3b90118#diff-31315cbee32dff759fd6d17e6d8939e67a292dc9e6c05591e4b95462a5ef1c43R44

@hoisie
It might seem a bit abrupt, but are you aware of this?

@hoisie
Copy link

hoisie commented Mar 31, 2024

Robolectric 4.11 adds support for the native runtime (native SQLite and graphics modes) on Windows.
https://github.com/robolectric/robolectric/releases/tag/robolectric-4.12

Just to be clear, this was a typo, and should read 4.12 release.

Windows seems to be a lot more protective of files that have been opened in native code. For instance, unlike in Mac and Linux, it's not possible to delete the temp native runtime DLL file in the same process where it was opened. We are seeing something similar with font files too. This is why we have extra cleanup logic for Windows.

@hoisie
Copy link

hoisie commented Mar 31, 2024

I am not sure that the FileSystemException errors you are seeing are causing test failures:

ERROR: Failed to destroy temp directory

java.nio.file.FileSystemException: C:\Users\RUNNER~1\AppData\Local\Temp\robolectric-nativeruntime12669726669700075741\fonts\CarroisGothicSC-Regular.ttf: The process cannot access the file because it is being used by another process

This deletion logic occurs in a shutdown hook, so it would run after all tests are complete. I think we should completely remove these error messages on Windows, because they will cause a lot of noise and confusion.

I think that the tests are failing due to other reasons.

@SimonMarquis
Copy link
Contributor

You are probably right. I can't test it further since I don't have my Windows machine with me, but the errors seem to come from other IO Exceptions.

com.google.samples.apps.nowinandroid.ui.NiaAppScreenSizesScreenshotTests > expandedWidth_compactHeight_showsNavigationRail FAILED
    java.io.IOException at SingleProcessDataStore.kt:433
        Caused by: java.io.IOException at NiaAppScreenSizesScreenshotTests.kt:126

@SimonMarquis
Copy link
Contributor

SimonMarquis commented Apr 1, 2024

Renders with Windows runners are different for the NavigationBar / NavigationRail tests:

SimonMarquis@6e4e7b5

Screenshots
compactWidth_compactHeight_showsNavigationBar_compare
compactWidth_expandedHeight_showsNavigationBar_compare
compactWidth_mediumHeight_showsNavigationBar_compare
expandedWidth_compactHeight_showsNavigationRail_compare

@hoisie
Copy link

hoisie commented Apr 2, 2024

https://github.com/robolectric/robolectric/releases/tag/robolectric-4.12.1 was just released which should reduce the amount of log noise in Windows (though it won't fix the underlying cause of this issue).

RE comparing screenshots across platforms (i.e. Linux / Mac / Linux):
There are no guarantees that rendering will be consistent across different platforms. The underlying native libraries (e.g. skia, minikin, etc..) have platform-specific implementation details.

@SimonMarquis
Copy link
Contributor

SimonMarquis commented Apr 2, 2024

Could this be an issue related to Looper/Dispatcher that would not behave exactly the same?
I feel like the screenshots are not rendering the expected "state".

There are some state setup in @Before that does not seem to be applied on Windows (hence the screenshot differences)

// Configure user data
runBlocking {
userDataRepository.setShouldHideOnboarding(true)
userDataRepository.setFollowedTopicIds(
setOf(topicsRepository.getTopics().first().first().id),
)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants