The sandbox diff drops a path that differs from another only by letter case, and its order depends on the string manager

Aperta Adatta ai principianti
#2,539 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
backend

Direzione di ricerca

Leggi TGocciaSandboxContext.DiffJson e DiffUnified in source/units/Goccia.Sandbox.Context.pas, quindi esamina le impostazioni vicine delle liste ordinate per individuare la convenzione di ordinamento del motore. Aggiorna solo gli elenchi dei percorsi e aggiungi test per nomi che differiscono solo per maiuscole e minuscole, creati, modificati e rimossi, oltre a un insieme fisso di nomi con punteggiatura e differenze tra maiuscole e minuscole. Il lavoro è completato quando entrambi i diff includono ogni percorso una sola volta e nello stesso ordine ordinale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug engine

Summary

The sandbox's run diff leaves out a path that differs from another path only by letter case. The sandbox file system keeps both files, but --diff-file and the embedding API's diff list only one of them.

Why

A diff that silently omits a created, changed or removed file misreports what a run did. An embedder that writes back or reviews changes from the diff loses one of the two files.

Current behavior

TGocciaSandboxContext.DiffJson and DiffUnified (source/units/Goccia.Sandbox.Context.pas) collect the current and baseline paths into TStringLists. They set Sorted := True and keep the defaults: CaseSensitive = False, Duplicates = dupIgnore, UseLocale = True. Two paths that are equal except for case therefore become one entry, and the second never reaches the diff.

On main at 484a9f74:

import fs from "fs";
fs.writeFileSync("/A.txt", "upper");
fs.writeFileSync("/a.txt", "lower");
console.log(JSON.stringify(fs.readdirSync("/")));

GocciaRunner --sandbox --diff-file=diff.json case.js prints ["A.txt","a.txt","case.js"], and both files read back their own contents. diff.json lists only one of them:

{ "changes": [ { "kind": "create", "path": "/A.txt", "oldBytes": 0, "newBytes": 5 } ], "metadataChanges": [] }

A change to, or removal of, the dropped twin is lost the same way.

The order of changes is also not determined by the paths alone. It follows AnsiCompareText, so it depends on the string manager the process installs. The engine's ProcessEncoding folds ASCII letters to lower case. An embedder that also links cwstring gets the locale's collation instead: under en_US.UTF-8, windmill.png sorts before windmill-sheet.png; under C, after it.

Expected behavior

  • Every changed path appears once, compared case-sensitively, as the file system names it.
  • The order of changes is ordinal and does not depend on the host's locale or string manager (CaseSensitive := True and UseLocale := False, as the engine's other sorted lists already set).
  • DiffJson and DiffUnified agree.

Scope notes

  • Only the path lists in DiffJson and DiffUnified. CollectPaths and the file system are unchanged.
  • Tests:
    • case twins created, changed and removed each appear in both diffs;
    • a fixed set of names with punctuation and case comes out in the same ordinal order.
  • The order of changes for names that differ only in punctuation or case will change for embedders that relied on the previous order.

[!NOTE]
Created on behalf of @frostney using Claude Opus 5.5.

Lingua principale
Pascal
Stelle
21
Fork
6
Merge medio
13h 48m
PR unite (30g)
286

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di frostney/GocciaScript

Tutte le issue di frostney/GocciaScript

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.