@@ -294,6 +294,30 @@ fn run_executes_module() {
294294 ) ;
295295}
296296
297+ /// inference recurses with the shape of the expression it is checking, and `run`
298+ /// checks on the thread it was dispatched to rather than through the rayon pool.
299+ /// on the stack a process starts with — 1 MiB on windows — a file like this one
300+ /// overflowed before that thread was sized for the work
301+ #[ test]
302+ fn run_checks_a_deeply_nested_expression ( ) {
303+ let dir = tempfile:: tempdir ( ) . expect ( "tempdir" ) ;
304+ let terms = vec ! [ "1" ; 2000 ] . join ( " + " ) ;
305+ fs:: write ( dir. path ( ) . join ( "main.by" ) , format ! ( "print({terms})\n " ) ) . unwrap ( ) ;
306+
307+ let output = Command :: new ( env ! ( "CARGO_BIN_EXE_by" ) )
308+ . args ( [ "run" , "main" ] )
309+ . current_dir ( dir. path ( ) )
310+ . output ( )
311+ . expect ( "failed to spawn by" ) ;
312+
313+ assert ! (
314+ output. status. success( ) ,
315+ "by run failed:\n {}" ,
316+ String :: from_utf8_lossy( & output. stderr)
317+ ) ;
318+ assert_eq ! ( String :: from_utf8_lossy( & output. stdout) . trim( ) , "2000" ) ;
319+ }
320+
297321#[ test]
298322fn run_force_unwrap_yields_inner_value ( ) {
299323 // `Some(x)` lowers to the `Optional(x)` wrapper; force-unwrapping it must
@@ -1780,17 +1804,36 @@ fn build_writes_a_sourcemap_beside_the_generated_python() {
17801804 let out = dir. path ( ) . join ( "out" ) ;
17811805 let map = fs:: read_to_string ( out. join ( "_by_sourcemap.py" ) ) . expect ( "sourcemap module" ) ;
17821806
1783- // the paths in the map are the ones the build ran against, so a symlinked
1784- // temp dir (`/tmp` on macOS) is spelled resolved there and has to be here
1785- let resolved = fs:: canonicalize ( & out) . expect ( "out directory" ) ;
1786- let py_key = format ! ( "{:?}" , resolved. join( "main.py" ) . to_string_lossy( ) ) ;
1807+ // read the keys out of the file rather than rebuilding them: the build
1808+ // spells a path the way the system handed it over, which is neither the
1809+ // test's `dir.path()` (a symlink under `/tmp` on macOS) nor its canonical
1810+ // form (a `\\?\` path with the long directory name on windows)
1811+ let first_key_of = |table : & str | {
1812+ let ( _, body) = map
1813+ . split_once ( & format ! ( "{table} = {{\n " ) )
1814+ . unwrap_or_else ( || panic ! ( "no {table} table:\n {map}" ) ) ;
1815+ let entry = body. lines ( ) . next ( ) . expect ( "an entry" ) ;
1816+ entry
1817+ . trim ( )
1818+ . split_once ( ": " )
1819+ . unwrap_or_else ( || panic ! ( "no key in {table}:\n {map}" ) )
1820+ . 0
1821+ . to_owned ( )
1822+ } ;
1823+
1824+ let mapped = first_key_of ( "SOURCEMAP" ) ;
17871825 assert ! (
1788- map . contains ( & format! ( "SOURCEMAP = {{ \n {py_key}: (" ) ) ,
1826+ mapped . ends_with ( "main.py \" " ) ,
17891827 "the generated module should be mapped by its own path:\n {map}"
17901828 ) ;
1829+ assert_eq ! (
1830+ mapped,
1831+ first_key_of( "DIGESTS" ) ,
1832+ "both tables key the same generated file:\n {map}"
1833+ ) ;
17911834 assert ! (
1792- map. contains( & format!( " {py_key }: {{\" by\" : \" sha256:" ) ) ,
1793- "and digested under the same key :\n {map}"
1835+ map. contains( & format!( "{mapped }: {{\" by\" : \" sha256:" ) ) ,
1836+ "the entry should carry a digest of each side :\n {map}"
17941837 ) ;
17951838 // the runner shim belongs to `by run`; a build output is not an entry point
17961839 assert ! (
0 commit comments