Oct
23
20 hours ago
started
started time in 2 hours ago
Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Apple Silicon support

Description

When perform robolectric test on Apple silicon, following error is raised

    Caused by: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97)
    	at com.almworks.sqlite4java.SQLite.getSQLiteVersion(SQLite.java:114)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.loadFromDirectory(SQLiteLibraryLoader.java:90)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.doLoad(SQLiteLibraryLoader.java:55)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.load(SQLiteLibraryLoader.java:39)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:73)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:80)
    	at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)

....
    Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
    	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
    	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
    	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
    	at java.base/java.lang.Runtime.load0(Runtime.java:768)
    	at java.base/java.lang.System.load(System.java:1837)
    	at com.almworks.sqlite4java.Internal.tryLoadFromPath(Internal.java:340)
    	at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:110)
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95)
    	... 36 more

Robolectric & Android Version

JVM : Jetbrains Runtime from Intellij IDEA 2020.3.2 ( OpenJDK 64-Bit Server VM JBR-11.0.9.1.11-1145.77-jcef (build 11.0.9.1+11-b1145.77, mixed mode) ) Robolectric : 4.5.1 Android Compile SDK : 30

utzcoz
utzcoz

Perhaps on Windows, libicu needs to be downloaded and installed separately? We could add support for an ICU_ROOT environment variable in the CMake file that is the root of the ICU installation (i.e the directory with 'lib' and 'bin'). This seems to be consistent with https://cmake.org/cmake/help/latest/module/FindICU.html.

I downloaded another libicu related library to fix this problem. But I encountered other compile problems: the compiler can't process define statement with constant value(/usr/include/ctype.h:66:17: error: expected ',' or '...' before numeric constant #define _X 0100). It also had other compile problems. The trying with MSYS2 is another choice.

Activity icon
issue

hoisie issue comment robolectric/robolectric

hoisie
hoisie

Apple Silicon support

Description

When perform robolectric test on Apple silicon, following error is raised

    Caused by: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97)
    	at com.almworks.sqlite4java.SQLite.getSQLiteVersion(SQLite.java:114)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.loadFromDirectory(SQLiteLibraryLoader.java:90)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.doLoad(SQLiteLibraryLoader.java:55)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.load(SQLiteLibraryLoader.java:39)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:73)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:80)
    	at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)

....
    Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
    	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
    	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
    	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
    	at java.base/java.lang.Runtime.load0(Runtime.java:768)
    	at java.base/java.lang.System.load(System.java:1837)
    	at com.almworks.sqlite4java.Internal.tryLoadFromPath(Internal.java:340)
    	at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:110)
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95)
    	... 36 more

Robolectric & Android Version

JVM : Jetbrains Runtime from Intellij IDEA 2020.3.2 ( OpenJDK 64-Bit Server VM JBR-11.0.9.1.11-1145.77-jcef (build 11.0.9.1+11-b1145.77, mixed mode) ) Robolectric : 4.5.1 Android Compile SDK : 30

hoisie
hoisie

Perhaps on Windows, libicu needs to be downloaded and installed separately? We could add support for an ICU_ROOT environment variable in the CMake file that is the root of the ICU installation (i.e the directory with 'lib' and 'bin'). This seems to be consistent with https://cmake.org/cmake/help/latest/module/FindICU.html.

Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Apple Silicon support

Description

When perform robolectric test on Apple silicon, following error is raised

    Caused by: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97)
    	at com.almworks.sqlite4java.SQLite.getSQLiteVersion(SQLite.java:114)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.loadFromDirectory(SQLiteLibraryLoader.java:90)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.doLoad(SQLiteLibraryLoader.java:55)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.load(SQLiteLibraryLoader.java:39)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:73)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:80)
    	at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)

....
    Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
    	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
    	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
    	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
    	at java.base/java.lang.Runtime.load0(Runtime.java:768)
    	at java.base/java.lang.System.load(System.java:1837)
    	at com.almworks.sqlite4java.Internal.tryLoadFromPath(Internal.java:340)
    	at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:110)
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95)
    	... 36 more

Robolectric & Android Version

JVM : Jetbrains Runtime from Intellij IDEA 2020.3.2 ( OpenJDK 64-Bit Server VM JBR-11.0.9.1.11-1145.77-jcef (build 11.0.9.1+11-b1145.77, mixed mode) ) Robolectric : 4.5.1 Android Compile SDK : 30

utzcoz
utzcoz

I created a new issue https://github.com/robolectric/robolectric/issues/6791 to track Windows support, and updates will be posted to that issue to keep this issue for Apple Silicon only.

Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Apple Silicon support

Description

When perform robolectric test on Apple silicon, following error is raised

    Caused by: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97)
    	at com.almworks.sqlite4java.SQLite.getSQLiteVersion(SQLite.java:114)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.loadFromDirectory(SQLiteLibraryLoader.java:90)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.doLoad(SQLiteLibraryLoader.java:55)
    	at org.robolectric.shadows.util.SQLiteLibraryLoader.load(SQLiteLibraryLoader.java:39)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:73)
    	at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:80)
    	at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)

....
    Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: dlopen(/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib, 1): no suitable image found.  Did find:
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	/private/var/folders/xp/t20n_5q54v9d7dz1rt9bk9k40000gp/T/1616114208715-0/libsqlite4java.dylib: no matching architecture in universal wrapper
    	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
    	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
    	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
    	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
    	at java.base/java.lang.Runtime.load0(Runtime.java:768)
    	at java.base/java.lang.System.load(System.java:1837)
    	at com.almworks.sqlite4java.Internal.tryLoadFromPath(Internal.java:340)
    	at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:110)
    	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95)
    	... 36 more

Robolectric & Android Version

JVM : Jetbrains Runtime from Intellij IDEA 2020.3.2 ( OpenJDK 64-Bit Server VM JBR-11.0.9.1.11-1145.77-jcef (build 11.0.9.1+11-b1145.77, mixed mode) ) Robolectric : 4.5.1 Android Compile SDK : 30

utzcoz
utzcoz

I finally can build nativeruntime with cygwin, but it encounter icu header problem similar with https://github.com/robolectric/robolectric/issues/6311#issuecomment-942334360. I will investigate more to fix missed components.

started
started time in 15 hours ago
Activity icon
issue

song-water issue comment robolectric/robolectric

song-water
song-water

static use of Android classes fails with ParameterizedRobolectricTestRunner

Description

I want to write a parameterized test whose data includes Android classes (android.location.Location), specifically. It appears, though, that ParameterizedRobolectricTestRunner installs the classloader too late, because if I create the test data objects in public static Collection<Object[]> data(), I get an exception saying the relevant method was not mocked (meaning the class loaded wasn't Robolectric's).

The same thing (creating a Location in a static block) succeeds with RobolectricTestRunner.

Test source code

@RunWith(ParameterizedRobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
public class ParameterizedTestTest{


	@ParameterizedRobolectricTestRunner.Parameters
	public static Collection<Object[]> data(){
		Location location = new Location("test");
		location.setTime(System.currentTimeMillis());
		return Arrays.asList(new Object[][]{
			{location}
		});
	}


	private final Location location;


	public ParameterizedTestTest(Location l){
		this.location = l;
	}


	@Test
	public void test(){

	}


}

Robolectric & Android Version

3.6.1 & 23

song-water
song-water

Hi, is there any actual progress on this issue?

This is still present in 4.6.1.

https://github.com/robolectric/robolectric/blob/master/robolectric/src/test/java/org/robolectric/ParameterizedRobolectricTestRunnerClassLoaderTest.java is work well in my PC, but fail with Kotlin :

@RunWith(ParameterizedRobolectricTestRunner::class)
  class ParameterizedRobolectricTestRunnerDemoTest(
      private var uri: Uri
  ) {
      @Test
      @Config(manifest = Config.NONE)
      fun parse() {
          val currentUri = Uri.parse("http://host/")
          assertThat(currentUri).isEqualTo(uri)
      }
  
      companion object {
          @ParameterizedRobolectricTestRunner.Parameters
          @JvmStatic
          fun getTestData(): Collection<*> {
              val data = arrayOf(arrayOf<Any>(Uri.parse("http://host/")))
              return listOf(data)
          }
      }
  }

error log:

parse("http://host/") must not be null
java.lang.NullPointerException: parse("http://host/") must not be null

Test environment

Robolectric: 4.6.1 Kotlin: 1.5.31 AGP: 7.0.0 JDK: 11 PC: windows 10

Oct
22
1 day ago
Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Move some ShadowMediaMuxer's tests to ctesque

Description

ShadowMediaMuxerTest uses AndroidJUnit4 to run tests, so it can be moved to ctesque to check related tests on emulator too. It can be done after https://github.com/robolectric/robolectric/pull/6570.

Steps to Reproduce

None.

Robolectric & Android Version

4.7-SNAPSHOT.

Link to a public git repo demonstrating the problem:

None.

utzcoz
utzcoz

When I am trying to moving it, I found this error when running tests on emulator:

10-23 01:08:27.416  2864  2880 I TestRunner: started: basicMuxingFlow_sameNonZeroOffset(android.media.MediaMuxerTest)
10-23 01:08:27.425  2864  2880 F MPEG4Writer: frameworks/av/media/libstagefright/MPEG4Writer.cpp:2103 CHECK(success) failed.
10-23 01:08:27.484  2912  2912 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
10-23 01:08:27.485  1687  1687 I /system/bin/tombstoned: received crash request for pid 2880
10-23 01:08:27.486  2912  2912 I crash_dump32: performing dump of process 2864 (target tid = 2880)
10-23 01:08:27.734  1687  1687 E /system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_00

Looks like current test code failed to write sample data to temporary MP4 file.

Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

when run unittest with RobolectricTestRunner,jacoco generate coverage report with zero data

Description

I want to generate coverage report for a library project。Found that if run unit test case with RobolectricTestRunner I could not get coverage data in the coverage report。 My library project build.gradle is below:

apply plugin: 'com.android.library' apply plugin: 'jacoco'

android { compileSdkVersion 29

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        testCoverageEnabled true
    }
}
testBuildType 'debug'

}

jacoco { toolVersion = "0.8.5" } task jacocoTestReport(type: JacocoReport) { group = "Reporting" description = "Generate Jacoco coverage reports after running tests." def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes", excludes: ['/R*.class', '/*MainActivity.class', ]) def coverageSourceDirs = "${project.projectDir}/src/main/java" reports { xml.enabled = true html.enabled = true } classDirectories = files(debugTree) sourceDirectories = files(coverageSourceDirs) executionData = files("$buildDir/jacoco/testDebugUnitTest.exec") }

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'androidx.test:core:1.0.0'
testImplementation 'org.mockito:mockito-core:2.28.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

library project has a only one simple java class: package com.example.mylibrary;

public class Hello {

public static String hello() {
    return "hello";
}

}

unittest case is below: package com.example.mylibrary;

import android.os.Build;

import org.junit.Test; import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**

  • Example local unit test, which will execute on the development machine (host).
  • @see Testing documentation */ //@RunWith(RobolectricTestRunner.class) //@Config(manifest= Config.NONE,sdk = Build.VERSION_CODES.P) public class ExampleUnitTest { @Test public void hello() { assertTrue(Hello.hello() == "hello"); } }

I run test and get report like this in terminal

./gradlew testDebugUnitTest jacocoTestReport

get test result report and coverage report image

but if run the case with RobolectricTestRunner,I get zero coverage in report。 @RunWith(RobolectricTestRunner.class) @Config(manifest= Config.NONE,sdk = Build.VERSION_CODES.P) public class ExampleUnitTest { @Test public void hello() { assertTrue(Hello.hello() == "hello"); } }

much thks for any idea

utzcoz
utzcoz

Any update on this issue? I'm facing the same thing.

Hi @zhangkevd , you can try https://github.com/arturdm/jacoco-android-gradle-plugin . I tested it locally, and it can generate coverage report for kotlin tests with Robolectric 4.6.1 for java source code. If you encountered jdk class not found, you can add following configuration to fix it:

    testOptions {
        unitTests {
            all {
                testLogging {
                    ....
                    jacoco {
                        includeNoLocationClasses = true
                        excludes = ['jdk.internal.*']
                    }
                }
            }
            ...
        }
    }

Although it uses 0.8.5 jacoco as example, you can use 0.8.7 with this plugin. After executing ./gradlew jacocoTestReport, you can execute find . -iname index.html to find generated index.html. My test project's generated path is ./app/build/jacoco/jacocoHtml/index.html.

Previous