budziq / rust-skeptic

Test your Rust Markdown documentation via Cargo
Apache License 2.0
285 stars 43 forks source link

Update pulldown-cmark to 0.7 #116

Closed ignatenkobrain closed 3 years ago

ignatenkobrain commented 4 years ago

Incorporates #108

ignatenkobrain commented 4 years ago

So I have been trying to figure out what's wrong with CI here…

Error: Error(UnequalLengths { pos: Some(Position { byte: 14, line: 2, record: 1 }), expected_len: 3, len: 5 })
test delimiter_sect_read_csv_records_with_different_delimiter_line_7 ... FAILED

This means, CSV parsing fails. Reading documentation:

This error occurs when two records with an unequal number of fields are found. This error only occurs when the flexible option in a CSV reader/writer is disabled.

That would mean that skeptic now generates somehow corrupted data from doctest. And in some very specific way since it affects only this particular test.

Hobbling some internals of skeptic, I got saved generated test file and flags how it is being compiled:

"rustc" "/tmp/test.rs" "--verbose" "--crate-type=bin" "--edition=2015" "-L" "/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug" "-L" "/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps" "--target" "x86_64-unknown-linux-gnu" "--extern" "glob=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libglob-48e6309e8ceff1bc.rlib" "--extern" "image=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libimage-f3f8dba321d0d428.rlib" "--extern" "select=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libselect-4717e4ae5ec05f25.rlib" "--extern" "percent_encoding=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libpercent_encoding-690300441a836cd4.rlib" "--extern" "chrono=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libchrono-7f219e37f4347580.rlib" "--extern" "csv=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libcsv-3ddacc53910a84ba.rlib" "--extern" "cc=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libcc-ed6e84817fa403e4.rlib" "--extern" "serde_json=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libserde_json-d452ca22e92f7d6a.rlib" "--extern" "byteorder=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libbyteorder-deeea4962fe40038.rlib" "--extern" "url=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/liburl-c15f604dcbc0e016.rlib" "--extern" "crossbeam=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libcrossbeam-2a43b917c7abbb40.rlib" "--extern" "base64=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libbase64-b4e4e94975c62687.rlib" "--extern" "ndarray=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libndarray-0f2f8cdb8f7f392e.rlib" "--extern" "crossbeam_channel=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libcrossbeam_channel-0889d3cc2b2e1420.rlib" "--extern" "tempfile=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libtempfile-92aa5ec7ea939863.rlib" "--extern" "lazy_static=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/liblazy_static-1bed6942fb4f0acf.rlib" "--extern" "serde=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libserde-9de74b5a6a5a68d2.rlib" "--extern" "toml=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libtoml-60caddb3d15e0259.rlib" "--extern" "ring=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libring-3fca219f6b86f2cd.rlib" "--extern" "data_encoding=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libdata_encoding-9ddd9748e6bb3b5d.rlib" "--extern" "skeptic=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libskeptic-83609d5184f7276c.rlib" "--extern" "mime=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libmime-4e42a022faaffecd.rlib" "--extern" "regex=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libregex-7d7872a380ee6ed7.rlib" "--extern" "memmap=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libmemmap-7410609c9a9170b3.rlib" "--extern" "clap=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libclap-1db2661bb2cd589c.rlib" "--extern" "flate2=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libflate2-2637eae23dc621ae.rlib" "--extern" "walkdir=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libwalkdir-2656412dfb4f79dd.rlib" "--extern" "num=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libnum-54e50d897d4bf770.rlib" "--extern" "threadpool=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libthreadpool-494e2a2869ae779e.rlib" "--extern" "num_cpus=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libnum_cpus-28301b07bd130581.rlib" "--extern" "reqwest=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libreqwest-60b63c5ea1f3ba65.rlib" "--extern" "ansi_term=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libansi_term-40f2790f913a4d9f.rlib" "--extern" "error_chain=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/liberror_chain-9ff0f8be2fcda714.rlib" "--extern" "nalgebra=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libnalgebra-e44e75cdbbe77946.rlib" "--extern" "tar=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libtar-fd14696f7d40bc2a.rlib" "--extern" "unicode_segmentation=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libunicode_segmentation-cfb671305a2b6935.rlib" "--extern" "petgraph=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libpetgraph-65a47e7080528b70.rlib" "--extern" "rand=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/librand-d528e2affc4d1173.rlib" "--extern" "semver=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libsemver-0d7626f36c2deb34.rlib" "--extern" "bitflags=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libbitflags-b67897ddfe60e690.rlib" "--extern" "same_file=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/libsame_file-e9191baed5286001.rlib" "--extern" "rayon=/home/brain/Projects/src.fedoraproject.org/rpms/rust-skeptic/rust-cookbook/target/debug/deps/librayon-68e749bca54e4888.rlib" "-o" "/tmp/out.exe"

And yes, running /tmp/out.exe fails with exactly same error:

Error: Error(UnequalLengths { pos: Some(Position { byte: 14, line: 2, record: 1 }), expected_len: 3, len: 5 })

Fair enough. Now I tried to create brand new project which would basically execute this code (so that I can debug it more easily).

$ cargo new foo
$ cd foo
$ cp /tmp/test.rs src/main.rs
$ echo -e 'csv = "1"\nserde = "1"\nserde_derive = "1"' >> Cargo.toml
$ cargo run

And yes, it fails same way. Looking into the RUSTC_BACKTRACE=1 of failing cargo test, I can see the source code skeptic generates (with all tests). Copying test body from there works just fine.

Ok, now time to run diff. The difference is that new version is generating testing code as-is while previous version was replacing tabs with spaces. Instead of 2 tabs (as in .md file), it generated 8 spaces. And since tab is delimiter, it fails.

I was trying to find out when this behavior has changed in pulldown-cmark and it was somewhere between 0.2 and 0.3 when entire crate was basically rewritten with new algorithm.


In the end, I decided not to waste my time on this since I think the cookbook should be fixed instead (do not use tabs in the code).

ignatenkobrain commented 4 years ago

@budziq let me know what you think :)

djc commented 3 years ago

Hi @ignatenkobrain, I'm closing this in favor of a cleaned up PR, #126. It still has a failing test, any help you can offer is much appreciated.