Commit 43210238 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

support wildcard aliases in filter tokens

parent eb444a00
Loading
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -1850,6 +1850,7 @@ if __name__ == "__main__":
            "(3) Output format (ENC/DEC): MONO, STEREO, BINAURAL, BINAURAL_ROOM_IR, "
            "BINAURAL_ROOM_REVERB, 5_1, 7_1, 5_1_4, 5_1_2, 7_1_4, FOA, HOA2, HOA3, EXT. "
            "Aliases: HOA -> HOA2+HOA3, SBA -> FOA+HOA2+HOA3, MC -> 5_1+7_1+5_1_4+5_1_2+7_1_4. "
            "Wildcard prefixes are also supported for tags/formats (e.g., ISAR*, BINAURAL*). "
            "These tokens restrict ENC/DEC tests at any level by output format; under LEVEL1 they apply on top of LEVEL1 constraints. "
            "(4) Substring: any other plain token is matched case-insensitively against the test "
            "command line. Multiple plain tokens are combined with logical AND. "
@@ -1863,6 +1864,8 @@ if __name__ == "__main__":
            "'--filter DEC HOA' — run DEC tests with HOA2/HOA3 outputs; "
            "'--filter DEC SBA' — run DEC tests with FOA/HOA2/HOA3 outputs; "
            "'--filter DEC MC' — run DEC tests with multichannel outputs (5_1, 7_1, 5_1_4, 5_1_2, 7_1_4); "
            "'--filter ISAR*' — run ISAR and ISAR_ENC groups; "
            "'--filter DEC BINAURAL*' — run DEC tests for all BINAURAL* output formats; "
            "'--filter DEC JBM' — run DEC tests containing 'JBM'; "
            "'--filter DEC +BINAURAL' — run all DEC tests plus those containing 'BINAURAL'; "
            "'--filter DEC -voip' — run all DEC tests except those containing 'voip'."
@@ -1962,6 +1965,41 @@ if __name__ == "__main__":

        upper_tok = base_tok.upper()

        # Prefix wildcard selection for tags and decoder output formats, e.g. ISAR*, BINAURAL*.
        if upper_tok.endswith("*") and len(upper_tok) > 1:
            prefix = upper_tok[:-1]
            matched_tags = sorted(t for t in valid_tags if t.startswith(prefix))
            matched_format_tokens = sorted(
                f for f in valid_decoder_formats if f.startswith(prefix)
            )

            if not matched_tags and not matched_format_tokens:
                parser.error(
                    f"Wildcard token '{tok}' did not match any known tag or decoder output format."
                )

            if sign == "+":
                tag_add_tokens.extend(matched_tags)
            elif sign == "-":
                tag_remove_tokens.extend(matched_tags)
            else:
                tag_tokens.extend(matched_tags)

            expanded_wildcard_formats = []
            for fmt in matched_format_tokens:
                expanded_wildcard_formats.extend(
                    sorted(DECODER_OUTPUT_FORMAT_ALIASES.get(fmt, {fmt}))
                )

            if sign == "+":
                additive_terms.extend(expanded_wildcard_formats)
            elif sign == "-":
                subtractive_terms.extend(expanded_wildcard_formats)
            else:
                decoder_format_tokens.extend(expanded_wildcard_formats)

            continue

        if upper_tok in valid_levels:
            if sign:
                parser.error(f"Level token '{tok}' cannot be prefixed with '+' or '-'.")