mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-06 20:32:44 +08:00
feat: add gadb pull folder/file
This commit is contained in:
8
.github/workflows/smoketest.yml
vendored
8
.github/workflows/smoketest.yml
vendored
@@ -24,8 +24,16 @@ jobs:
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9'
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install funppy httprunner
|
||||
- name: Build hrp binary
|
||||
run: make build
|
||||
- name: Run smoketest - run with parameters
|
||||
|
||||
8
.github/workflows/unittest.yml
vendored
8
.github/workflows/unittest.yml
vendored
@@ -23,8 +23,14 @@ jobs:
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9'
|
||||
- name: Install Python plugin dependencies
|
||||
run: python3 -m pip install funppy
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install funppy httprunner
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Run coverage
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -45,3 +45,7 @@ dist
|
||||
*.egg-info
|
||||
.python-version
|
||||
.pytest_cache
|
||||
|
||||
# generated go module files in templates
|
||||
internal/scaffold/templates/plugin/go.mod
|
||||
internal/scaffold/templates/plugin/go.sum
|
||||
|
||||
@@ -1 +1 @@
|
||||
v5.0.0-250803
|
||||
v5.0.0-250806
|
||||
|
||||
@@ -610,6 +610,55 @@ func (d *Device) Pull(remotePath string, dest io.Writer) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (d *Device) PullFolder(remotePath string, localPath string) (err error) {
|
||||
// Check if remote path exists and is a directory
|
||||
fileInfos, err := d.List(remotePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to list remote directory: %w", err)
|
||||
}
|
||||
|
||||
// Create local directory if it doesn't exist
|
||||
if err = os.MkdirAll(localPath, 0o755); err != nil {
|
||||
return fmt.Errorf("failed to create local directory: %w", err)
|
||||
}
|
||||
|
||||
// Pull each file/directory recursively
|
||||
for _, fileInfo := range fileInfos {
|
||||
remoteItemPath := remotePath + "/" + fileInfo.Name
|
||||
localItemPath := localPath + "/" + fileInfo.Name
|
||||
|
||||
if fileInfo.IsDir() {
|
||||
// Recursively pull subdirectory
|
||||
if err = d.PullFolder(remoteItemPath, localItemPath); err != nil {
|
||||
return fmt.Errorf("failed to pull subdirectory %s: %w", remoteItemPath, err)
|
||||
}
|
||||
} else {
|
||||
// Pull file
|
||||
if err = d.PullFile(remoteItemPath, localItemPath); err != nil {
|
||||
return fmt.Errorf("failed to pull file %s: %w", remoteItemPath, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Device) PullFile(remotePath string, localPath string) (err error) {
|
||||
// Create local file
|
||||
localFile, err := os.Create(localPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create local file: %w", err)
|
||||
}
|
||||
defer localFile.Close()
|
||||
|
||||
// Use existing Pull method to pull file content
|
||||
if err = d.Pull(remotePath, localFile); err != nil {
|
||||
return fmt.Errorf("failed to pull file content: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Device) installViaABBExec(apk io.ReadSeeker, args ...string) (raw []byte, err error) {
|
||||
var (
|
||||
tp transport
|
||||
|
||||
@@ -296,6 +296,17 @@ func TestDevice_Pull(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDevice_PullFolder(t *testing.T) {
|
||||
setupDevices(t)
|
||||
|
||||
for _, dev := range devices {
|
||||
err := dev.PullFolder("/storage/emulated/0/Download/", "/tmp/test/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDevice_ScreenRecord(t *testing.T) {
|
||||
setupDevices(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user