mitsuhiko / minijinja

MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2
https://docs.rs/minijinja/
Apache License 2.0
1.67k stars 101 forks source link

test_random failing on 32b architectures #621

Closed omnivagant closed 2 weeks ago

omnivagant commented 2 weeks ago

When packaging this for alpinelinux, I noticed that the test_random test failed for our armhf, armv7 and x86 targets

test test_random ... FAILED

failures:

---- test_random stdout ----
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: random-2
Source: minijinja-contrib/tests/filters.rs:105
────────────────────────────────────────────────────────────────────────────────
Expression: render!(in env, r"{% set RAND_SEED = 42 %}{{ 'HelloWorld'|random }}")
────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────
    0       │-e
          0 │+l
────────────┴───────────────────────────────────────────────────────────────────
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'test_random' panicked at /home/buildozer/.cargo/registry/src/index.crates.io-1cd66030c949c28d/insta-1.39.0/src/runtime.rs:562:9:
snapshot assertion for 'random-2' failed in line 105
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    test_random

test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s

error: test failed, to rerun pass `-p minijinja-contrib --test filters`

and, with the above test patched out:

test test_randrange ... FAILED
test test_lispum ... FAILED

failures:

---- test_randrange stdout ----
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: randrange
Source: minijinja-contrib/tests/globals.rs:83
────────────────────────────────────────────────────────────────────────────────
Expression: render!(in env, r"{% set RAND_SEED = 42 %}{{ randrange(10) }}")
────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────
    0       │-1
          0 │+3
────────────┴───────────────────────────────────────────────────────────────────
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'test_randrange' panicked at /home/buildozer/.cargo/registry/src/index.crates.io-1cd66030c949c28d/insta-1.39.0/src/runtime.rs:562:9:
snapshot assertion for 'randrange' failed in line 83
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- test_lispum stdout ----
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: lispum
Source: minijinja-contrib/tests/globals.rs:54
────────────────────────────────────────────────────────────────────────────────
Expression: render!(in env, r"{% set RAND_SEED = 42 %}{{ lipsum(5) }}")
────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────
    0       │-Facilisi accumsan class rutrum integer euismod gravida cras vsociis arcu lobortis sociosqu elementum lacus nulla. Leo imperdiet penatibus id quam malesuada pretium sociosqu scelerisque diam sociosqu penatibus imperdiet et nisl. Ante s vulputate nulla porta ssociis per gravida primis porta penatibus nostra congue dui.
          0 │+Habitasse accumsan convallis fermentum penatibus ssociis quis lorem ridiculus sociosqu cursus litora nostra id lorem per. Senectus ad dui sociosqu proin sociosqu pellentesque sociosqu scelerisque vsociis ssociis posuere condimentum sociis. Posuere porttitor potenti sem penatibus curae quis imperdiet ssociis eleifend vulputate ac nec. A lectus sociosqu consectetuer.
    1     1 │ 
    2       │-Ipsum cras integer magna ssociis etiam eu rutrum ac praesent ssociis primis nisl malesuada sociosqu. Senectus sem neque ridiculus aliquet duis nisl facilisis quam diam nibh ad eget. Rutrum mauris aliquam faucibus magna eu phasellus ssociis libero neque convallis magna. Ante aliquet proin montes nibh sociosqu vulputate auctor.
          2 │+Sociosqu facilisis potenti ssociis inceptos phasellus integer ssociis inceptos vsociis risus sagittis ssociis semper etiam dapibus congue. Malesuada nulla sociosqu facilisi facilisis purus egestas inceptos ssociis feugiat sociis diam vulputate mus. Nam eget lorem iaculis ac lorem auctor nullam hymenaeos curabitur integer. Arcu sociosqu neque adipiscing senectus luctus curabitur ssociis nascetur commodo ad nostra. Orci ssociis sociosqu potenti adipiscing nisl nec proin ssociis nulla quisque sociosqu platea. Sociosqu cras.
    3     3 │ 
    4       │-Lacinia aliquam dictumst pellentesque nibh sociosqu sagittis leo ad dictum elementum sapien mi sociosqu. Et ssociis laoreet dolor egestas scelerisque potenti duis natoque ssociis feugiat. Proin luctus porta rhoncus quis phasellus netus non proin sociosqu nonummy ornare lacinia. Leo sociis inceptos cum leo non elit class sed sapien dictum diam mattis dapibus netus facilisis. Hendrerit montes aliquam ssociis ridiculus a cras sociosqu nisi ssociis curabitur.
          4 │+Sociosqu orci ac mollis per luctus sem phasellus primis convallis ssociis nec lorem sociosqu pharetra. Nulla et mollis quam sed felis curae sem consequat sociosqu sociis massa scelerisque molestie.
    5     5 │ 
    6       │-Justo nonummy pulvinar potenti in potenti at facilisi platea sagittis scelerisque quis sapien semper dictum in ipsum. Nunc nonummy ornare etiam elementum nullam curae eu nullam ad nascetur ssociis nullam mus. Nisi ssociis gravida dapibus non sociosqu laoreet adipiscing potenti ipsum parturient potenti mollis odio. Leo eget felis pretium libero consectetuer hymenaeos sociosqu ssociis in posuere.
          6 │+Cursus eu sociosqu aliquam habitant quam leo id sociosqu inceptos at ssociis mauris lectus sagittis. Dictum morbi leo lectus ssociis sed pulvinar quam sociosqu ac sociosqu laoreet pellentesque. Justo ad vulputate quis donec metus risus aenean penatibus condimentum mauris ornare nec.
    7     7 │ 
    8       │-S commodo fames ridiculus luctus proin non aptent nullam mi eleifend consectetuer aliquam ad. Scelerisque nisl blandit sociis euismod curae semper nunc nec litora condimentum fames habitasse. Inceptos augue sociosqu hendrerit justo montes orci proin mus molestie id iaculis nostra lacus. Cum facilisis potenti facilisis nonummy sem.
          8 │+Ssociis vsociis sem pulvinar luctus elementum diam habitant dapibus sed nisi ssociis est hac aenean. Class etiam amet condimentum sociosqu a duis a id habitasse ssociis habitasse. Ligula nulla accumsan pretium sociosqu aliquet sociosqu nisl ligula ssociis rutrum est massa sem. Sociosqu consequat sociosqu consequat facilisi etiam erat enim adipiscing quisque eleifend per. Fringilla augue amet ssociis nullam odio commodo leo semper sociosqu dignissim natoque luctus sociosqu rhoncus dolor maecenas. Aliquet consectetuer nonummy inceptos justo blandit dolor risus amet ligula ssociis pellentesque nam.
────────────┴───────────────────────────────────────────────────────────────────
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'test_lispum' panicked at /home/buildozer/.cargo/registry/src/index.crates.io-1cd66030c949c28d/insta-1.39.0/src/runtime.rs:562:9:
snapshot assertion for 'lispum' failed in line 54

failures:
    test_lispum
    test_randrange

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s

error: test failed, to rerun pass `-p minijinja-contrib --test globals`
mitsuhiko commented 2 weeks ago

That's because the RNG is pointer size specific. I will disable those tests on 32bit platforms.

omnivagant commented 2 weeks ago

fwiw, this is what I ended up with https://git.alpinelinux.org/aports/commit/?id=d9c98a355435cf05ecd137b444b75c9c006111da