Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
rzo1 committed Jan 17, 2025
1 parent fb843ed commit 914707e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/shell-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
14 changes: 11 additions & 3 deletions opennlp-distr/src/test/ps/test_opennlp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
}

0 comments on commit 914707e

Please sign in to comment.