You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by rz...@apache.org on 2025/01/17 12:03:23 UTC
(opennlp) 03/03: x
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
commit 914707e01df63960106d2dbfce59d46c79917077
Author: Richard Zowalla <rz...@apache.org>
AuthorDate: Fri Jan 17 13:03:08 2025 +0100
x
---
.github/workflows/shell-tests.yml | 13 +++++++------
opennlp-distr/src/test/ps/test_opennlp.Tests.ps1 | 14 +++++++++++---
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/shell-tests.yml b/.github/workflows/shell-tests.yml
index 6469e873..54da3d1a 100644
--- a/.github/workflows/shell-tests.yml
+++ b/.github/workflows/shell-tests.yml
@@ -151,28 +151,29 @@ jobs:
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
+ # Extract the tar.gz file to the user profile directory
$Destination = "$env:USERPROFILE"
tar -xzf $TAR_FILE.FullName -C $Destination
- # Get the directory name of the extracted content
+ # Get the directory name of the extracted content (excluding the tar path)
$EXTRACTED_DIR = (tar -tf $TAR_FILE.FullName | Select-Object -First 1).Split('/')[0]
-
- # Set OPENNLP_HOME dynamically
+
+ # Set OPENNLP_HOME dynamically in the environment
echo "OPENNLP_HOME=$env:USERPROFILE\$EXTRACTED_DIR" >> $GITHUB_ENV
echo "$env:USERPROFILE\$EXTRACTED_DIR\bin" >> $GITHUB_PATH
- name: Verify Extraction
run: |
+ # Print the OPENNLP_HOME and check if the 'bin' directory exists
echo "OPENNLP_HOME: $env:OPENNLP_HOME"
- dir $env:OPENNLP_HOME\bin
+ dir "$env:OPENNLP_HOME\bin"
- name: Run Pester Tests
run: |
diff --git a/opennlp-distr/src/test/ps/test_opennlp.Tests.ps1 b/opennlp-distr/src/test/ps/test_opennlp.Tests.ps1
index 44fcc30f..d8cd895f 100644
--- a/opennlp-distr/src/test/ps/test_opennlp.Tests.ps1
+++ b/opennlp-distr/src/test/ps/test_opennlp.Tests.ps1
@@ -2,16 +2,21 @@ Describe "opennlp.bat Tests" {
# Setup before all tests
BeforeAll {
+ # Ensure OPENNLP_HOME is added to PATH
$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"
+
+ # Ensure the .bat file exists
$batFile | Should -Exist
- # Check if the bat file is executable (on Windows, this means it's a valid executable script)
+ # Check if the bat file runs by executing it with a help flag
$result = & $batFile -h
+
+ # Validate the result isn't null or empty
$result | Should -Not -BeNullOrEmpty
}
@@ -20,19 +25,22 @@ Describe "opennlp.bat Tests" {
$input = "Hello, friends"
$expected_output = "Hello , friends"
- # Run the opennlp.bat with SimpleTokenizer
- $output = & "$env:OPENNLP_HOME\bin\opennlp.bat" SimpleTokenizer <<< $input
+ # Run the opennlp.bat with SimpleTokenizer, using input redirection via echo
+ $output = echo $input | & "$env:OPENNLP_HOME\bin\opennlp.bat" SimpleTokenizer
# Debugging: Log the output
Write-Host "Output: $output"
# Validate the command executed successfully
$output | Should -Not -BeNullOrEmpty
+
+ # Check if the expected output is in the result
$output | Should -Contain $expected_output
}
# Cleanup after tests
AfterAll {
+ # Remove OPENNLP_HOME from PATH after tests are done
Remove-Item Env:\PATH -ErrorAction SilentlyContinue
}
}