Skip to content

Commit ecd986c

Browse files
committed
feat(integration): add --skip option to exclude tests from CI
Add ability to skip specific integration tests via testdata-skip.txt file. Changes: - Add get_integration_tests() to share test discovery logic - Add --skip flag to setup.py --list-tests - Update all-integration-tests.sh to accept --skip as third argument - Add testdata-skip.txt for listing tests to exclude - Enable --skip in GitHub Actions workflow
1 parent 38e5175 commit ecd986c

File tree

4 files changed

+89
-49
lines changed

4 files changed

+89
-49
lines changed

.github/workflows/run_integration_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
run: python3 setup.py --exclude-tests -w .
3939

4040
- name: Run integration tests
41-
run: ./scripts/all-integration-tests.sh ./gno/gno.land/pkg/integration .
41+
run: ./scripts/all-integration-tests.sh ./gno/gno.land/pkg/integration . --skip

scripts/all-integration-tests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# Run all integration tests individually
3-
# Usage: ./scripts/run-all-tests.sh [GNO_INTEGRATION_PATH] [CONTRACT_PATH]
3+
# Usage: ./scripts/all-integration-tests.sh [GNO_INTEGRATION_PATH] [CONTRACT_PATH] [--skip]
44

55
set -e
66

@@ -14,6 +14,7 @@ NC='\033[0m' # No Color
1414
# Default paths (can be overridden by arguments)
1515
GNO_INTEGRATION_PATH="${1:-/app/gno/gno.land/pkg/integration}"
1616
CONTRACT_PATH="${2:-/app}"
17+
SKIP_FLAG="${3:-}"
1718

1819
# Convert to absolute paths
1920
GNO_INTEGRATION_PATH="$(cd "$GNO_INTEGRATION_PATH" && pwd)"
@@ -27,7 +28,7 @@ cd "$GNO_INTEGRATION_PATH"
2728
tests=()
2829
while IFS= read -r test; do
2930
tests+=("$test")
30-
done < <(cd "$CONTRACT_PATH" && python3 setup.py --list-tests)
31+
done < <(cd "$CONTRACT_PATH" && python3 setup.py --list-tests $SKIP_FLAG)
3132

3233
total=${#tests[@]}
3334
passed=0

setup.py

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,36 @@ def setup_contracts(workdir: str, exclude_tests: bool = False) -> None:
186186
copier.process_directory(root, dirs, files)
187187

188188

189+
def get_integration_tests() -> list:
190+
"""Get all integration tests with their source paths and converted names.
191+
192+
Returns:
193+
List of tuples: (src_file_path, converted_name)
194+
"""
195+
src_testdata = "tests/integration/testdata"
196+
197+
if not os.path.exists(src_testdata):
198+
return []
199+
200+
tests = []
201+
for root, _, files in os.walk(src_testdata):
202+
for file in files:
203+
if file.endswith(".txtar"):
204+
src_file = os.path.abspath(os.path.join(root, file))
205+
rel_dir = os.path.relpath(root, src_testdata)
206+
name_without_ext = file.replace(".txtar", "")
207+
208+
if rel_dir != ".":
209+
prefix = rel_dir.replace(os.sep, "_") + "_"
210+
converted_name = prefix + name_without_ext
211+
else:
212+
converted_name = name_without_ext
213+
214+
tests.append((src_file, converted_name))
215+
216+
return tests
217+
218+
189219
def copy_integration_tests(workdir: str) -> None:
190220
"""Copy integration test files from tests/integration to gno/gno.land/pkg/integration."""
191221
module_manager = GnoModuleManager(workdir)
@@ -206,32 +236,16 @@ def copy_integration_tests(workdir: str) -> None:
206236

207237
print(f"Copying integration tests from {src_testdata} to {dest_testdata}")
208238

209-
# Walk through all directories and find txtar files
210-
for root, _, files in os.walk(src_testdata):
211-
for file in files:
212-
if file.endswith(".txtar"):
213-
src_file = os.path.abspath(os.path.join(root, file))
214-
215-
# Calculate relative path from src_testdata
216-
rel_dir = os.path.relpath(root, src_testdata)
217-
218-
# If file is in a subdirectory, add directory name as prefix
219-
if rel_dir != ".":
220-
# Convert nested paths to prefix (e.g., "gov/governance" -> "gov_governance_")
221-
prefix = rel_dir.replace(os.sep, "_") + "_"
222-
dest_filename = prefix + file
223-
else:
224-
dest_filename = file
225-
226-
dest_file = os.path.join(dest_testdata, dest_filename)
239+
for src_file, converted_name in get_integration_tests():
240+
dest_file = os.path.join(dest_testdata, converted_name + ".txtar")
227241

228-
# Remove existing file/link if present
229-
if os.path.exists(dest_file) or os.path.islink(dest_file):
230-
os.unlink(dest_file)
242+
# Remove existing file/link if present
243+
if os.path.exists(dest_file) or os.path.islink(dest_file):
244+
os.unlink(dest_file)
231245

232-
# Create symlink
233-
os.symlink(src_file, dest_file)
234-
print(f" Linked: {file} -> {dest_filename}")
246+
# Create symlink
247+
os.symlink(src_file, dest_file)
248+
print(f" Linked: {os.path.basename(src_file)} -> {converted_name}.txtar")
235249

236250
# Copy bless directory
237251
src_bless = "tests/integration/bless"
@@ -264,33 +278,32 @@ def copy_integration_tests(workdir: str) -> None:
264278
print(f" Linked: {file}")
265279

266280

267-
def list_integration_tests() -> None:
281+
def load_skip_tests(skip_file: str) -> set:
282+
"""Load skip list from file."""
283+
skip_tests = set()
284+
if os.path.exists(skip_file):
285+
with open(skip_file) as f:
286+
for line in f:
287+
line = line.strip()
288+
if line and not line.startswith("#"):
289+
skip_tests.add(line)
290+
return skip_tests
291+
292+
293+
def list_integration_tests(skip: bool = False) -> None:
268294
"""List all integration tests with their converted names."""
269-
src_testdata = "tests/integration/testdata"
295+
skip_file = "tests/integration/testdata-skip.txt"
270296

271-
if not os.path.exists(src_testdata):
297+
tests = get_integration_tests()
298+
if not tests:
272299
print("Error: Test directory not found", file=sys.stderr)
273300
sys.exit(1)
274301

275-
tests = []
276-
for root, _, files in os.walk(src_testdata):
277-
for file in files:
278-
if file.endswith(".txtar"):
279-
# Get relative directory from testdata root
280-
rel_dir = os.path.relpath(root, src_testdata)
281-
name_without_ext = file.replace(".txtar", "")
302+
skip_tests = load_skip_tests(skip_file) if skip else set()
282303

283-
# If in subdirectory, add prefix
284-
if rel_dir != ".":
285-
prefix = rel_dir.replace(os.sep, "_") + "_"
286-
converted_name = prefix + name_without_ext
287-
else:
288-
converted_name = name_without_ext
289-
290-
tests.append(converted_name)
291-
292-
for test in sorted(tests):
293-
print(test)
304+
for _, converted_name in sorted(tests, key=lambda x: x[1]):
305+
if converted_name not in skip_tests:
306+
print(converted_name)
294307

295308

296309
def main() -> None:
@@ -315,11 +328,16 @@ def main() -> None:
315328
action="store_true",
316329
help="List all integration tests with converted names",
317330
)
331+
parser.add_argument(
332+
"--skip",
333+
action="store_true",
334+
help="Exclude tests listed in testdata-skip.txt",
335+
)
318336

319337
args = parser.parse_args()
320338

321339
if args.list_tests:
322-
list_integration_tests()
340+
list_integration_tests(skip=args.skip)
323341
return
324342

325343
if args.clone:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Integration tests to skip
2+
# Add test names (without .txtar extension) one per line
3+
# Lines starting with # are comments
4+
5+
# GNO native function gas measurement
6+
base_comment_gas_measurement
7+
base_cross_realm_depth_gas_measurement
8+
base_data_structure_gas_measurement
9+
base_pkg_realm_call_gas_measurement
10+
base_realm_load_cost_measurement
11+
base_storage_gas_measurement
12+
base_strconv_gas_measurement
13+
base_string_concat_gas_measurement
14+
15+
# Time relative tests
16+
gov_governance_cancel_active_proposal_should_fail
17+
gov_governance_create_community_pool_spend_proposal
18+
gov_governance_create_parameter_change_proposal
19+
gov_governance_create_text_proposal
20+
gov_governance_execute_text_proposal_should_fail
21+
gov_governance_execute_unfinished_proposal_should_fail

0 commit comments

Comments
 (0)