feat: make --version return java package version (#748)
This commit is contained in:
@@ -26,3 +26,6 @@ jobs:
|
||||
run: mvn install -D skipTests --no-transfer-progress
|
||||
- name: Test CLI
|
||||
run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -f playwright/pom.xml -D exec.args=-V
|
||||
- name: Test CLI version
|
||||
shell: bash
|
||||
run: tools/test-cli-version/test.sh
|
||||
|
||||
@@ -35,6 +35,10 @@ public class CLI {
|
||||
if (!pb.environment().containsKey("PW_CLI_TARGET_LANG")) {
|
||||
pb.environment().put("PW_CLI_TARGET_LANG", "java");
|
||||
}
|
||||
String version = Playwright.class.getPackage().getImplementationVersion();
|
||||
if (version != null) {
|
||||
pb.environment().put("PW_CLI_DISPLAY_VERSION", version);
|
||||
}
|
||||
pb.inheritIO();
|
||||
Process process = pb.start();
|
||||
System.exit(process.waitFor());
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>test-cli-version</artifactId>
|
||||
<version>1.18.0-SNAPSHOT</version>
|
||||
<name>Test Playwright Command Line Version</name>
|
||||
<properties>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.microsoft.playwright.testcliversion;
|
||||
|
||||
import com.microsoft.playwright.Playwright;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestApp {
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
String version = Playwright.class.getPackage().getImplementationVersion();
|
||||
if (version == null) {
|
||||
throw new RuntimeException("FAIL: Version is null");
|
||||
}
|
||||
System.out.println("ImplementationVersion " + version);
|
||||
}
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set +x
|
||||
|
||||
trap "cd $(pwd -P)" EXIT
|
||||
cd "$(dirname $0)"
|
||||
|
||||
TMP_DIR=$(mktemp -d)
|
||||
echo "Created ${TMP_DIR}"
|
||||
|
||||
echo "Running CLI..."
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="--version" 2>&1 | tee ${TMP_DIR}/cli.txt
|
||||
|
||||
echo "Running TestApp..."
|
||||
mvn compile exec:java -e -Dexec.mainClass=com.microsoft.playwright.testcliversion.TestApp 2>&1 | tee ${TMP_DIR}/app.txt
|
||||
|
||||
CLI_VERSION=$(cat ${TMP_DIR}/cli.txt | tail -n 1 | cut -d\ -f2)
|
||||
PACKAGE_VERSION=$(cat ${TMP_DIR}/app.txt | grep ImplementationVersion | cut -d\ -f2)
|
||||
|
||||
rm -rf $TMP_DIR
|
||||
|
||||
echo "Comparing versions: ${CLI_VERSION} and ${PACKAGE_VERSION}"
|
||||
|
||||
if [[ "$CLI_VERSION" == "$PACKAGE_VERSION" ]];
|
||||
then
|
||||
echo "SUCCESS.";
|
||||
else
|
||||
echo "FAIL.";
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
This derictory is populated with test files from playwright and playwright-driver projects. They are copied
|
||||
This directory is populated with test files from playwright and playwright-driver projects. They are copied
|
||||
here on each test run.
|
||||
|
||||
Reference in New Issue
Block a user