Skip to content

Commit 914707e

Browse files
committed
x
1 parent fb843ed commit 914707e

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.github/workflows/shell-tests.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,29 @@ jobs:
151151
run: |
152152
# Find the first non-src .tar.gz file in the target directory
153153
$TAR_FILE = Get-ChildItem -Path opennlp-distr/target -Filter "*.tar.gz" | Where-Object { $_.Name -notlike "*-src*" } | Select-Object -First 1
154-
154+
155155
# Ensure we found a file
156156
if (-not $TAR_FILE) {
157157
Write-Error "Error: No matching tar.gz file found in opennlp-distr/target"
158158
exit 1
159159
}
160160
161-
# Extract the tar.gz file
161+
# Extract the tar.gz file to the user profile directory
162162
$Destination = "$env:USERPROFILE"
163163
tar -xzf $TAR_FILE.FullName -C $Destination
164164
165-
# Get the directory name of the extracted content
165+
# Get the directory name of the extracted content (excluding the tar path)
166166
$EXTRACTED_DIR = (tar -tf $TAR_FILE.FullName | Select-Object -First 1).Split('/')[0]
167-
168-
# Set OPENNLP_HOME dynamically
167+
168+
# Set OPENNLP_HOME dynamically in the environment
169169
echo "OPENNLP_HOME=$env:USERPROFILE\$EXTRACTED_DIR" >> $GITHUB_ENV
170170
echo "$env:USERPROFILE\$EXTRACTED_DIR\bin" >> $GITHUB_PATH
171171
172172
- name: Verify Extraction
173173
run: |
174+
# Print the OPENNLP_HOME and check if the 'bin' directory exists
174175
echo "OPENNLP_HOME: $env:OPENNLP_HOME"
175-
dir $env:OPENNLP_HOME\bin
176+
dir "$env:OPENNLP_HOME\bin"
176177
177178
- name: Run Pester Tests
178179
run: |

opennlp-distr/src/test/ps/test_opennlp.Tests.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ Describe "opennlp.bat Tests" {
22

33
# Setup before all tests
44
BeforeAll {
5+
# Ensure OPENNLP_HOME is added to PATH
56
$env:PATH = "$env:OPENNLP_HOME\bin;$env:PATH"
67
}
78

89
# Test if opennlp.bat is accessible and executable
910
It "opennlp.bat exists and is executable" {
1011
$batFile = Join-Path $env:OPENNLP_HOME "bin\opennlp.bat"
12+
13+
# Ensure the .bat file exists
1114
$batFile | Should -Exist
1215

13-
# Check if the bat file is executable (on Windows, this means it's a valid executable script)
16+
# Check if the bat file runs by executing it with a help flag
1417
$result = & $batFile -h
18+
19+
# Validate the result isn't null or empty
1520
$result | Should -Not -BeNullOrEmpty
1621
}
1722

@@ -20,19 +25,22 @@ Describe "opennlp.bat Tests" {
2025
$input = "Hello, friends"
2126
$expected_output = "Hello , friends"
2227

23-
# Run the opennlp.bat with SimpleTokenizer
24-
$output = & "$env:OPENNLP_HOME\bin\opennlp.bat" SimpleTokenizer <<< $input
28+
# Run the opennlp.bat with SimpleTokenizer, using input redirection via echo
29+
$output = echo $input | & "$env:OPENNLP_HOME\bin\opennlp.bat" SimpleTokenizer
2530

2631
# Debugging: Log the output
2732
Write-Host "Output: $output"
2833

2934
# Validate the command executed successfully
3035
$output | Should -Not -BeNullOrEmpty
36+
37+
# Check if the expected output is in the result
3138
$output | Should -Contain $expected_output
3239
}
3340

3441
# Cleanup after tests
3542
AfterAll {
43+
# Remove OPENNLP_HOME from PATH after tests are done
3644
Remove-Item Env:\PATH -ErrorAction SilentlyContinue
3745
}
3846
}

0 commit comments

Comments
 (0)