This is an automated email from the ASF dual-hosted git repository.

yuchanns pushed a commit to branch bindings-go-doc
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit dea43790675f3add1382a150675fed15011611df
Author: Hanchin Hsieh <[email protected]>
AuthorDate: Thu Apr 10 13:01:23 2025 +0800

    doc(bindings/go): better Linux test script
    
    Hanchin Hsieh <[email protected]>
---
 bindings/go/README.md | 45 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/bindings/go/README.md b/bindings/go/README.md
index e71bb6535..f4f79fe7c 100644
--- a/bindings/go/README.md
+++ b/bindings/go/README.md
@@ -237,20 +237,56 @@ go work use ./opendal-go-services/memory
 cat <<EOF > ./make_test.sh
 #!/bin/bash
 
+# Check if OPENDAL_TEST is set
+if [ -z "\$OPENDAL_TEST" ]; then
+    echo "Error: OPENDAL_TEST environment variable is not set"
+    echo "Please set OPENDAL_TEST to specify which backend to test (e.g., fs 
or memory)"
+    exit 1
+fi
+
+# Specify the backend to test
+export SERVICE="\$OPENDAL_TEST"
+
+# Get architecture
 architecture=\$(uname -m)
-if [ "\$architecture" = "x86_64" ]\;\; then
+if [ "\$architecture" = "x86_64" ]; then
     ARCH="x86_64"
-elif [ "\$architecture" = "aarch64" ] || [ "\$architecture" = "arm64" ]\;\; 
then
+elif [ "\$architecture" = "aarch64" ] || [ "\$architecture" = "arm64" ]; then
     ARCH="arm64"
 else
     ARCH="unknown"
 fi
 
+# Build opendal
 cd opendal/bindings/c
 cargo build
 cd -
-zstd -19 opendal/bindings/c/target/debug/libopendal_c.so -o 
opendal-go-services/fs/libopendal_c.linux.\$ARCH.so.zst
 
+# Set environment variables
+export GITHUB_WORKSPACE="\$PWD/opendal-go-services"
+export VERSION="latest"
+export TARGET="linux"
+export DIR="\$GITHUB_WORKSPACE/libopendal_c_\$VERSION_\$SERVICE_\$TARGET"
+
+# Create directory if not exists
+mkdir -p "\$DIR"
+
+export OUTPUT="\$DIR/libopendal_c_\$VERSION_\$SERVICE_\$TARGET.so"
+# Compress with zstd
+zstd -19 opendal/bindings/c/target/debug/libopendal_c.so -o \$OUTPUT
+
+# Generate code
+cd opendal-go-services/internal/generate
+go run generate.go
+cd -
+
+# Delete unnecessary files
+rm -rf \$DIR
+
+# Set environment variables for test
+export MATRIX='{"build": [{"target":"linux", "goos":"linux", "goarch": 
"amd64"}], "service": ["fs"]}'
+
+# Run tests
 go test ./opendal/bindings/go/tests/behavior_tests -v -run TestBehavior
 EOF
 
@@ -279,6 +315,7 @@ cd -
   For Windows
   </summary>
 
+
 ```powershell
 New-Item -ItemType Directory -Path opendal_workspace
 Set-Location -Path opendal_workspace
@@ -294,7 +331,7 @@ go work use ./opendal-go-services/fs
 go work use ./opendal-go-services/memory
 
 @'
-# Specify the backend to test\;Set-Item -Path Env:SERVICE -Value 
"$env:OPENDAL_TEST"\;# Get architecture\;$architecture = (Get-WmiObject 
Win32_OperatingSystem).OSArchitecture\;\;if ($architecture -like "*64*") {\;    
$ARCH = "x86_64"\;} else {\;    $ARCH = "unknown" \;}\;\;# Build 
opendal\;Push-Location opendal/bindings/c\;cargo build\;Pop-Location\;\;# 
Rename dll file\;Rename-Item opendal/bindings/c/target/debug/opendal_c.dll 
libopendal_c.dll\;\;# Set environment variables\;Set-Item -Pa [...]
+# Check if OPENDAL_TEST is set\;if (-not $env:OPENDAL_TEST) {\;    Write-Error 
"OPENDAL_TEST environment variable is not set"\;    Write-Host "Please set 
OPENDAL_TEST to specify which backend to test (e.g., fs or memory)"\;    exit 
1\;}\;# Specify the backend to test\;Set-Item -Path Env:SERVICE -Value 
"$env:OPENDAL_TEST"\;# Get architecture\;$architecture = (Get-WmiObject 
Win32_OperatingSystem).OSArchitecture\;\;if ($architecture -like "*64*") {\;    
$ARCH = "x86_64"\;} else {\;    $ARCH [...]
 '@ -replace "\\;","`n" | Out-File -FilePath "MakeTest.ps1" -Encoding UTF8
 
 Pop-Location

Reply via email to