feat: new test dir
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
张泊明518370910136 2024-05-20 17:50:53 -04:00
parent a042ac01ea
commit f9dd4e9b68
GPG Key ID: D47306D7062CDA9D
6 changed files with 36 additions and 3 deletions

1
.gitignore vendored
View File

@ -124,3 +124,4 @@ $RECYCLE.BIN/
build/
!examples/**/*.out
tmp/

View File

@ -15,4 +15,5 @@ prepare-test:
git submodule update --init --remote
test:
./scripts/prepare_test_repos.sh
go test -coverprofile cover.out -v ./...

View File

@ -63,7 +63,7 @@ func readStageResults(t *testing.T, path string) []stage.StageResult {
func TestMain(t *testing.T) {
var tests []string
root := "../../examples/"
root := "../../tmp/submodules/JOJ3-examples"
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err

@ -1 +1 @@
Subproject commit 3ebebbc913534fb4c4598d3ed313d1bb3ff29020
Subproject commit 6cbfd9ff1ea95cd5c6c5f832e99cda6f9f2ea851

@ -1 +1 @@
Subproject commit 4bca6f0e4b5e263532b8410afecca615e90524e9
Subproject commit b1afead762d2b2704823af83847c9155c6a1422b

31
scripts/prepare_test_repos.sh Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -ex
declare -A repo_names
tmp_dir="./tmp"
submodules_dir="$tmp_dir/submodules"
rm -rf $submodules_dir
mkdir -p $submodules_dir
submodules=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')
for submodule in $submodules; do
url=$(git config --file .gitmodules --get-regexp "submodule.$submodule.url" | awk '{ print $2 }')
repo_name=$(echo $url | rev | cut -d'/' -f 1 | rev | cut -d'.' -f 1)
commit=$(git submodule status $submodule | awk '{ print $1 }' | sed 's/^[+-]//')
repo_dir="$tmp_dir/$repo_name"
if [[ ! -v repo_names["$repo_name"] ]]; then
if [ ! -d "$repo_dir" ]; then
git clone $url $repo_dir
else
cd $repo_dir
git fetch --all
cd -
fi
fi
repo_names[$repo_name]=1
cd $repo_dir
git checkout -q $commit
cd -
submodule_dir="$submodules_dir/$repo_name/$submodule"
mkdir -p $submodule_dir
cp -rT $repo_dir $submodule_dir
done