This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch OPENNLP-1688
in repository https://gitbox.apache.org/repos/asf/opennlp.git
The following commit(s) were added to refs/heads/OPENNLP-1688 by this push:
new b314f06e x
b314f06e is described below
commit b314f06eecb1125d77c949a7953b82233dc6fea0
Author: Richard Zowalla <[email protected]>
AuthorDate: Fri Jan 17 12:56:53 2025 +0100
x
---
.../{unix-shell-tests.yml => shell-tests.yml} | 64 ++++++++++++++++++++++
opennlp-distr/src/test/ps/test_opennlp.Tests.ps1 | 38 +++++++++++++
2 files changed, 102 insertions(+)
diff --git a/.github/workflows/unix-shell-tests.yml
b/.github/workflows/shell-tests.yml
similarity index 63%
rename from .github/workflows/unix-shell-tests.yml
rename to .github/workflows/shell-tests.yml
index 1758e330..10899e9e 100644
--- a/.github/workflows/unix-shell-tests.yml
+++ b/.github/workflows/shell-tests.yml
@@ -119,6 +119,70 @@ jobs:
- name: Run Bats Tests
run: |
bats ./opennlp-distr/src/test/sh
+ env:
+ JAVA_HOME: ${{ env.JAVA_HOME }}
+ OPENNLP_HOME: ${{ env.OPENNLP_HOME }}
+
+ test-windows-shell:
+ name: Test opennlp.bat on Windows
+ runs-on: windows-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ # Install Pester for PowerShell testing
+ - name: Install Pester
+ run: |
+ Install-Module -Name Pester -Force -Scope CurrentUser
+ Import-Module Pester
+ shell: pwsh
+
+ # Set up JDK 17 for Windows (using Temurin distribution)
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ distribution: temurin
+ java-version: 17
+
+ # Build with Maven (same as the Linux setup)
+ - name: Build with Maven
+ run: mvn -V clean install --no-transfer-progress -Pci -DskipTests=true
+
+ # Find and Extract OpenNLP Distribution
+ - name: Find and Extract OpenNLP Distribution
+ run: |
+ # Find the first non-src .tar.gz file in the target directory
+ $TAR_FILE = Get-ChildItem -Path opennlp-distr/target -Filter
"*.tar.gz" | Where-Object { $_.Name -notlike "*-src*" } | Select-Object -First 1
+
+ # Ensure we found a file
+ if (-not $TAR_FILE) {
+ Write-Error "Error: No matching tar.gz file found in
opennlp-distr/target"
+ exit 1
+ }
+
+ # Extract the tar.gz file
+ $Destination = "$env:USERPROFILE"
+ tar -xzf $TAR_FILE.FullName -C $Destination
+
+ # Get the directory name of the extracted content
+ $EXTRACTED_DIR = (tar -tf $TAR_FILE.FullName | Select-Object -First
1).Split('/')[0]
+
+ # Set OPENNLP_HOME dynamically
+ echo "OPENNLP_HOME=$env:USERPROFILE\$EXTRACTED_DIR" >> $GITHUB_ENV
+ echo "$env:USERPROFILE\$EXTRACTED_DIR\bin" >> $GITHUB_PATH
+
+ # Verify Extraction
+ - name: Verify Extraction
+ run: |
+ echo "OPENNLP_HOME: $env:OPENNLP_HOME"
+ dir $env:OPENNLP_HOME\bin
+
+ # Run Pester Tests for opennlp.bat
+ - name: Run Pester Tests
+ run: |
+ Invoke-Pester -Script
"./opennlp-distr/test/ps/test_opennlp.Tests.ps1" -Output Detailed
+ shell: pwsh
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
OPENNLP_HOME: ${{ env.OPENNLP_HOME }}
\ No newline at end of file
diff --git a/opennlp-distr/src/test/ps/test_opennlp.Tests.ps1
b/opennlp-distr/src/test/ps/test_opennlp.Tests.ps1
new file mode 100644
index 00000000..44fcc30f
--- /dev/null
+++ b/opennlp-distr/src/test/ps/test_opennlp.Tests.ps1
@@ -0,0 +1,38 @@
+Describe "opennlp.bat Tests" {
+
+ # Setup before all tests
+ BeforeAll {
+ $env:PATH = "$env:OPENNLP_HOME\bin;$env:PATH"
+ }
+
+ # Test if opennlp.bat is accessible and executable
+ It "opennlp.bat exists and is executable" {
+ $batFile = Join-Path $env:OPENNLP_HOME "bin\opennlp.bat"
+ $batFile | Should -Exist
+
+ # Check if the bat file is executable (on Windows, this means it's a
valid executable script)
+ $result = & $batFile -h
+ $result | Should -Not -BeNullOrEmpty
+ }
+
+ # Test the output of SimpleTokenizer
+ It "SimpleTokenizer produces correct output" {
+ $input = "Hello, friends"
+ $expected_output = "Hello , friends"
+
+ # Run the opennlp.bat with SimpleTokenizer
+ $output = & "$env:OPENNLP_HOME\bin\opennlp.bat" SimpleTokenizer <<<
$input
+
+ # Debugging: Log the output
+ Write-Host "Output: $output"
+
+ # Validate the command executed successfully
+ $output | Should -Not -BeNullOrEmpty
+ $output | Should -Contain $expected_output
+ }
+
+ # Cleanup after tests
+ AfterAll {
+ Remove-Item Env:\PATH -ErrorAction SilentlyContinue
+ }
+}