Add OsSystem support to mdtests (#16518)

## Summary

This PR introduces a new mdtest option `system` that can either be
`in-memory` or `os`
where `in-memory` is the default.

The motivation for supporting `os` is so that we can write OS/system
specific tests
with mdtests. Specifically, I want to write mdtests for the module
resolver,
testing that module resolution is case sensitive. 

## Test Plan

I tested that the case-sensitive module resolver test start failing when
setting `system = "os"`
This commit is contained in:
Micha Reiser 2025-03-06 09:41:40 +00:00 committed by GitHub
parent 48f906e06c
commit ce0018c3cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 541 additions and 229 deletions

View file

@ -176,7 +176,7 @@ mod tests {
use crate::files::system_path_to_file;
use crate::source::{line_index, source_text};
use crate::system::{DbWithTestSystem, SystemPath};
use crate::system::{DbWithWritableSystem as _, SystemPath};
use crate::tests::TestDb;
#[test]
@ -184,13 +184,13 @@ mod tests {
let mut db = TestDb::new();
let path = SystemPath::new("test.py");
db.write_file(path, "x = 10".to_string())?;
db.write_file(path, "x = 10")?;
let file = system_path_to_file(&db, path).unwrap();
assert_eq!(source_text(&db, file).as_str(), "x = 10");
db.write_file(path, "x = 20".to_string()).unwrap();
db.write_file(path, "x = 20").unwrap();
assert_eq!(source_text(&db, file).as_str(), "x = 20");
@ -202,7 +202,7 @@ mod tests {
let mut db = TestDb::new();
let path = SystemPath::new("test.py");
db.write_file(path, "x = 10".to_string())?;
db.write_file(path, "x = 10")?;
let file = system_path_to_file(&db, path).unwrap();
@ -228,7 +228,7 @@ mod tests {
let mut db = TestDb::new();
let path = SystemPath::new("test.py");
db.write_file(path, "x = 10\ny = 20".to_string())?;
db.write_file(path, "x = 10\ny = 20")?;
let file = system_path_to_file(&db, path).unwrap();
let index = line_index(&db, file);