Skip to content

Commit

Permalink
Add tests and CI support for CPU detection
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Jan 19, 2024
1 parent d8d603a commit b75fe3d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: build with maven
run: |
mvn -q -N "io.takari:maven:${{env.IO_TAKARI_MAVEN_WRAPPER_VERSION}}:wrapper" "-Dmaven=${{env.MAVEN_VERSION}}"
./mvnw -B -ntp formatter:validate verify --file pom.xml "-Djava11.home=${{env.JAVA_HOME_11_X64}}"
./mvnw -B -ntp formatter:validate verify --file pom.xml "-Dexpected-cpu=x64" "-Djava11.home=${{env.JAVA_HOME_11_X64}}"
quality:
needs: [ build ]
Expand Down
20 changes: 20 additions & 0 deletions cpu/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,32 @@

<name>SmallRye Common: CPU</name>

<properties>
<expected-cpu/>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.github.dmlloyd.module-info</groupId>
<artifactId>module-info</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<expected-cpu>${expected-cpu}</expected-cpu>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
18 changes: 18 additions & 0 deletions cpu/src/test/java/io/smallrye/common/cpu/CPUTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.smallrye.common.cpu;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;

/**
*
*/
public final class CPUTests {

@Test
public void testCpu() {
String expectedCpuName = System.getProperty("expected-cpu");
Assumptions.assumeTrue(expectedCpuName != null && !expectedCpuName.isEmpty());
Assertions.assertEquals(CPU.host().name(), expectedCpuName);
}
}

0 comments on commit b75fe3d

Please sign in to comment.