Skip to content

Commit

Permalink
Merge pull request #96 from swiftwasm/katei/remove-submodules
Browse files Browse the repository at this point in the history
Checkout test suite repositories without git-submodules
  • Loading branch information
kateinoigakukun committed Jun 11, 2024
2 parents 17b9a64 + 2af7fb2 commit 3ece12e
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 19 deletions.
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

1 change: 1 addition & 0 deletions CI/check-spectest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ set -e
install_tools

SOURCE_DIR="$(cd $(dirname $0)/.. && pwd)"
./Vendor/checkout-dependency testsuite
exec make -C $SOURCE_DIR spectest
1 change: 1 addition & 0 deletions CI/check-wasi-testsuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ install_tools
SOURCE_DIR="$(cd $(dirname $0)/.. && pwd)"
(
cd $SOURCE_DIR && \
./Vendor/checkout-dependency wasi-testsuite && \
python3 -m pip install -r ./Vendor/wasi-testsuite/test-runner/requirements.txt && \
exec ./IntegrationTests/WASI/run-tests.sh
)
24 changes: 14 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,36 @@ test:
docs:
swift package generate-documentation --target WasmKit

WAST_ROOT = Vendor/testsuite
### Spectest (Core WebAssembly Specification Test Suite)

TESTSUITE_DIR = Vendor/testsuite
SPECTEST_ROOT = ./spectest
WAST_FILES = $(wildcard $(WAST_ROOT)/*.wast) $(wildcard $(WAST_ROOT)/proposals/memory64/*.wast)
JSON_FILES = $(WAST_FILES:$(WAST_ROOT)/%.wast=$(SPECTEST_ROOT)/%.json)
WAST_FILES = $(wildcard $(TESTSUITE_DIR)/*.wast) $(wildcard $(TESTSUITE_DIR)/proposals/memory64/*.wast)
JSON_FILES = $(WAST_FILES:$(TESTSUITE_DIR)/%.wast=$(SPECTEST_ROOT)/%.json)

.PHONY: spec
spec: $(JSON_FILES) $(SPECTEST_ROOT)/host.wasm

$(SPECTEST_ROOT)/host.wasm: ./Examples/wasm/host.wat
wat2wasm ./Examples/wasm/host.wat -o $(SPECTEST_ROOT)/host.wasm

$(SPECTEST_ROOT)/%.json: $(WAST_ROOT)/%.wast
$(TESTSUITE_DIR)/%.wast: $(TESTSUITE_DIR)
$(SPECTEST_ROOT)/%.json: $(TESTSUITE_DIR)/%.wast
@mkdir -p $(@D)
wast2json $^ -o $@

.PHONY: spectest
spectest: spec
swift run Spectest $(SPECTEST_ROOT)

.PHONY: clean
clean:
@swift package clean

.PHONY: update
update:
@swift package update
### WASI Test Suite

.PHONY: wasitest
wasitest:
./IntegrationTests/WASI/run-tests.sh

### Utilities

.PHONY: generate
generate:
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,15 @@ Add the URL of this repository to your `Package.swift` manifest. Then add the `W
To run the core spec test suite run this:

```sh
$ make spectest # Prepare core spec tests and check their assertions with WasmKit
# Checkout the core spec test suite
$ ./Vendor/checkout-dependency spectest
# Prepare core spec tests and check their assertions with WasmKit
$ make spectest

# Checkout WASI spec test suite
$ ./Vendor/checkout-dependency wasi-testsuite
# Install Python dependencies for running WASI spec tests
$ python3 -m pip install -r ./Vendor/wasi-testsuite/test-runner/requirements.txt
# Run WASI spec tests
$ make wasitest
```
2 changes: 2 additions & 0 deletions Vendor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/wasi-testsuite
/testsuite
40 changes: 40 additions & 0 deletions Vendor/checkout-dependency
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
#
# This script checks out a dependency from a git repository.
#
# Usage:
# checkout-dependency <dependency-name>

import os
import sys
import json
import subprocess


def main():
if len(sys.argv) != 2:
print("Usage: checkout-dependency <dependency-name>")
sys.exit(1)

dependency_name = sys.argv[1]
dependencies_file = os.path.join(os.path.dirname(__file__), "dependencies.json")
dependencies = json.load(open(dependencies_file))
dependency = dependencies.get(dependency_name)

if dependency is None:
print(f"Dependency '{dependency_name}' not found in {dependencies_file}")
print(f"Available dependencies: {', '.join(dependencies.keys())}")
sys.exit(1)

dependency_path = os.path.join(os.path.dirname(__file__), dependency_name)
if os.path.exists(dependency_path):
print(f"Dependency '{dependency_name}' already exists at {dependency_path}")
sys.exit(0)

print(f"Checking out '{dependency_name}' to {dependency_path}")
subprocess.run(["git", "clone", dependency["repository"], dependency_path], check=True)
subprocess.run(["git", "-C", dependency_path, "checkout", dependency["revision"]], check=True)


if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions Vendor/dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"testsuite": {
"repository": "https://github.com/WebAssembly/testsuite.git",
"revision": "7ef86ddeed81458f9031a49a40b3a3f99c1c6a8a"
},
"wasi-testsuite": {
"repository": "https://github.com/WebAssembly/wasi-testsuite.git",
"revision": "c9c751586fd86b321d595bbef13f2c7403cfdbc5"
}
}
1 change: 0 additions & 1 deletion Vendor/testsuite
Submodule testsuite deleted from 7ef86d
1 change: 0 additions & 1 deletion Vendor/wasi-testsuite
Submodule wasi-testsuite deleted from c9c751

0 comments on commit 3ece12e

Please sign in to comment.