Skip to content

Commit 206312b

Browse files
jamesadevineCopilot
andcommitted
fix: schema path, NodeTool step readability, and glob bracket guard
- Update test_write_schema_to_scripts to write to the canonical scripts/ado-script/schema/ path instead of the deleted scripts/gate-spec.schema.json location. - Convert NodeTool@0 step from escaped single-line string to a raw string literal, consistent with the adjacent download step. - Add logWarning guard in globMatch when pattern contains "[" to catch compiler/evaluator parity drift early (bracket expressions are treated as literals, not character classes). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 61df725 commit 206312b

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

scripts/ado-script/src/gate/predicates.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,14 @@ function stringsFromFact(raw: unknown): string[] {
167167

168168
function globMatch(value: string, pattern: string): boolean {
169169
// Glob → regex: only `*` (any chars) and `?` (single char) are
170-
// recognised. Bracket expressions like `[abc]` are escaped to literal
171-
// characters here. This is a deliberate divergence from Python's
172-
// `fnmatch.fnmatch`, which supports `[seq]` ranges. The IR currently
173-
// never emits bracket patterns, but if a future predicate needs them,
174-
// this builder must be extended (and the parity inventory updated).
170+
// recognised. Bracket expressions like `[abc]` are treated as literals.
171+
// The IR currently never emits bracket patterns; warn if one appears so
172+
// a compiler/evaluator parity drift is caught early.
173+
if (/\[/.test(pattern)) {
174+
logWarning(
175+
`globMatch: pattern "${pattern}" contains "[" which is treated as a literal, not a character class`,
176+
);
177+
}
175178
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
176179
const regex = `^${escaped.replace(/\\\*/g, ".*").replace(/\\\?/g, ".")}$`;
177180
return new RegExp(regex, "s").test(value);

src/compile/extensions/trigger_filters.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ impl CompilerExtension for TriggerFiltersExtension {
102102
// acceptable. NodeTool@0 is preinstalled on Microsoft-hosted and 1ES
103103
// images.
104104
steps.push(
105-
"- task: NodeTool@0\n inputs:\n versionSpec: \"20.x\"\n displayName: \"Install Node.js 20.x for gate evaluator\"\n condition: succeeded()".to_string(),
105+
r#"- task: NodeTool@0
106+
inputs:
107+
versionSpec: "20.x"
108+
displayName: "Install Node.js 20.x for gate evaluator"
109+
condition: succeeded()"#
110+
.to_string(),
106111
);
107112

108113
steps.push(format!(

src/compile/filter_ir.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,11 +1826,15 @@ mod tests {
18261826
#[test]
18271827
#[ignore] // Writes to source tree — run manually with `cargo test test_write_schema -- --ignored`
18281828
fn test_write_schema_to_scripts() {
1829-
// Generate schema and write to scripts/ for distribution
1829+
// Generate schema and write to the canonical location for codegen
18301830
let schema = generate_gate_spec_schema();
18311831
let schema_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
18321832
.join("scripts")
1833+
.join("ado-script")
1834+
.join("schema")
18331835
.join("gate-spec.schema.json");
1836+
std::fs::create_dir_all(schema_path.parent().unwrap())
1837+
.expect("should create schema dir");
18341838
std::fs::write(&schema_path, &schema).expect("should write schema file");
18351839

18361840
// Verify it's readable and valid

0 commit comments

Comments
 (0)