| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 3 个月前 | ||
| 2 个月前 | ||
| 3 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 3 个月前 | ||
| 3 个月前 |
dev-projects tests
Tests simple software project development in common languages (Python, Go, Rust, Node, C, ...) across multiple OS envs.
- Modular:
run.sh(main) +lib.sh(shared routines) +langs/*.sh(one script per language). - OSes:
ALL_OS="openeuler fedora debian ubuntu alpine archlinux conda"; create one env per OS, run all (or selected) lang tests inside it. - Selection:
-o OSrun a single OS;-t LANGrun a single test (e.g.-t python);-cremove env after run (default: leave for debug). - Reuse: Top-level support in
lib.sh(env create/remove,run_in_env, logging, timeout, arg parsing); per-lang scripts are thin and useENV_NAME,OS,EPKG_BINonly. - Run from repo root:
timeout 600 tests/dev-projects/run.sh -o ubuntu -t pythonortests/dev-projects/run.shfor full run (env removed before create, left for debug at end).
Layout
- run.sh — Main script: removes env if present, creates fresh env, runs lang tests. Each
run()/run_install()writes to a per-command log underLOG_DIR; on Error/Warning/WARN we stop and show that log. Never removes env at end (left for debug). - lib.sh — Shared routines:
ALL_OS, env create/remove (remove is idempotent; used only before create),run_in_env, log/error, timeout,-o/-tparsing. - common.sh — Sourced by each lang script: sets
LANG_NAMEfrom script name andSCRIPT_DIRfrom$0; requiresENV_NAME,EPKG_BIN(clear error if unset). Providesrun(),run_install()(with--ignore-missing),check_cmd(),lang_skip(),lang_ok(),run_ebin(),run_ebin_if(). - langs/*.sh — One script per language (python, go, rust, node, c). Each: one-line header, epkg install + check_cmd, minimal project build/run, then (if the lang has a pkg manager) install one pkg via it and verify (pip/npm/go get/cargo add). Runnable standalone:
ENV_NAME=dev-alpine OS=alpine EPKG_BIN=/path/to/epkg ./langs/c.sh(env must exist).
Usage
From repo root (epkg built):
# All OSes, all lang tests (env removed before create if present; left for debug at end)
tests/dev-projects/run.sh
# Single OS
tests/dev-projects/run.sh -o ubuntu
# Single failed test (e.g. python on alpine)
tests/dev-projects/run.sh -o alpine -t python
# Debug mode
tests/dev-projects/run.sh -d -o alpine -t c
With timeout:
timeout 600 tests/dev-projects/run.sh -o openeuler -t go
Testing Native Windows epkg.exe from WSL2
When developing epkg for Windows, you can run the dev-projects tests from WSL2 against a native Windows epkg.exe binary. This is useful for:
- Testing Windows builds without leaving the Linux development environment
- CI/CD pipelines that run on WSL2 but need to validate Windows binaries
- Cross-platform regression testing
WSL2 Test Script: run-wsl2-windows.sh
The run-wsl2-windows.sh script wraps run.sh with WSL2-specific configuration:
- Automatically detects WSL2 environment
- Sets
EPKG_BINto point to Windows epkg.exe - Translates
run_ebincalls to useepkg.exe runfor Linux distros (since they need VM execution)
# Test all languages on alpine from WSL2
tests/dev-projects/run-wsl2-windows.sh -o alpine
# Test only python on ubuntu
tests/dev-projects/run-wsl2-windows.sh -o ubuntu -t python
# Use custom epkg.exe location
tests/dev-projects/run-wsl2-windows.sh -e /mnt/c/ProgramData/epkg/epkg.exe -o alpine
# With debug mode
tests/dev-projects/run-wsl2-windows.sh -dd -o alpine -t python
Prerequisites
- Build epkg for Windows: Cross-compile or build natively on Windows
- Place epkg.exe: Default location is
/mnt/c/Users/$USER/epkg.exe, or specify with-e - WSL2: Must be running in a WSL2 distribution (not WSL1)
How It Works
When running from WSL2 against Linux distros (alpine, ubuntu, etc.):
run_ebin()detects non-Linux host via environment variables- Since Linux distros run in VM on Windows, epkg doesn't create ebin/ wrappers (ELF binaries need VM execution, creating wrappers is too complex and script interpreters are also ELF)
- Instead of executing
$ENV_ROOT/ebin/$bindirectly, it runs$EPKG_BIN -e $ENV_NAME run -- $bin "$@" - This invokes the Windows epkg.exe which runs the command inside the VM
For native Windows/macOS distros (msys2/conda/brew), ebin/ wrappers are still created and used directly.
Note: This same behavior also applies to macOS testing. On macOS, Linux distros need VM execution, so run_ebin() uses epkg run and ebin/ is empty. Native macOS homebrew packages use ebin/ wrappers directly.
Adding a language
Add langs/<name>.sh (executable). It must:
- One line:
. "$(dirname "$0")/../common.sh"(LANG_NAME is set from script name). run_install pkg1 pkg2 pkg3thencheck_cmd <tool> <version-flag> || lang_skip "reason".- Use
run cmd...for build/run steps. End withlang_ok.