From a9c4965dd620c086e5419f71117ec46de8fb5b99 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Mon, 28 Aug 2023 04:46:07 +0300 Subject: [PATCH] cicd: exclude hang tests for exotic arches and ASAN --- .github/workflows/sanitize.yml | 4 ++-- cli/src/tests/parser_hang_test.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sanitize.yml b/.github/workflows/sanitize.yml index 834c5ab4..2ece182b 100644 --- a/.github/workflows/sanitize.yml +++ b/.github/workflows/sanitize.yml @@ -36,14 +36,14 @@ jobs: env: UBSAN_OPTIONS: halt_on_error=1 CFLAGS: -fsanitize=undefined - RUSTFLAGS: -lubsan + RUSTFLAGS: ${{ env.RUSTFLAGS }} -lubsan run: cargo test -- --test-threads 1 - name: Run main tests with address sanitizer (ASAN) env: ASAN_OPTIONS: halt_on_error=1 CFLAGS: -fsanitize=address - RUSTFLAGS: -Zsanitizer=address + RUSTFLAGS: ${{ env.RUSTFLAGS }} -Zsanitizer=address --cfg=sanitizing run: | rustup install nightly rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu diff --git a/cli/src/tests/parser_hang_test.rs b/cli/src/tests/parser_hang_test.rs index ab4273e3..b8274804 100644 --- a/cli/src/tests/parser_hang_test.rs +++ b/cli/src/tests/parser_hang_test.rs @@ -1,3 +1,6 @@ +// For some reasons `Command::spawn` doesn't work in CI env for many exotic arches. +#![cfg(all(any(target_arch = "x86_64", target_arch = "x86"), not(sanitizing)))] + use crate::{ generate::{generate_parser_for_grammar, load_grammar_file}, tests::helpers::fixtures::{fixtures_dir, get_test_language}, @@ -8,6 +11,15 @@ use std::{ }; use tree_sitter::Parser; +// The `sanitizing` cfg is required to don't run tests under specific sunitizer +// because they don't work well with subprocesses _(it's an assumption)_. +// +// Bellow are two alternative examples of how to disable tests for some arches +// if a way with excluding the whole mod from compilation would work well. +// +// #[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), not(sanitizing)))] +// #[cfg_attr(not(all(any(target_arch = "x86_64", target_arch = "x86"), not(sanitizing))), ignore)] +// #[test] fn test_grammar_that_should_hang_and_not_segfault() { let parent_sleep_millis = 1000;