Show Error Message for Missing Crate

Following up from this conversation and linked to this post.

I wasn’t aware that only defined crates could be used in the rust track and tried to rerun the tests because I kept getting the message One of the tests timed out even though locally, the runner reported it took 0s to run all of them.

I would suggest showing a more explicit error if the crate cannot be found, e.g.

One of the crates referenced is not available in the test runner. Here's the [list of what's available](...). 

If you feel the crate you used should be added to the list, please create a [forum post](...) explaining why!

I haven’t looked at the test runner code, so I don’t know if that’s easily possible, but I’m willing to have a go at it if you agree that this makes sense.

phf is still included in the test runner. My PR removing a lot of crates did not include that.

I published an exercise solution with one of the dependencies that were removed (exists on crates.io) to check the error message. Seems reasonable to me:

image

Thank you for your reply!

My exact import was phf = { version = "0.11.2", features = ["macros"] }, maybe that makes a difference?

good question. after testing, looks like the answer is “no”

It seems most likely to me that you just got unlucky with the timeout?

Ok, it’s very strange: if I include both phf and regex in the dependencies, it fails with a timeout, regardless of the actual code:

pub fn brackets_are_balanced(string: &str) -> bool {
    true
}

with cargo

[package]
edition = "2021"
name = "matching-brackets"
version = "2.0.0"

[dependencies]
phf = { version = "0.11.2", features = ["macros"] }
regex = "1.10.4"

If I remove regex from the deps, the tests run just fine, e.g. with

use phf::phf_map;

static PAIRS: phf::Map<char, char> = phf_map! {
    ')' => '(',
    ']' => '[',
    '}' => '{',
};

pub fn brackets_are_balanced(string: &str) -> bool {
    let mut stack = Vec::<char>::new();
    for c in string.chars() {
        match c {
            '[' | '(' | '{' => stack.push(c),
            ']' | ')' | '}' => if stack.is_empty() || &stack.pop().unwrap() != PAIRS.get(&c).unwrap() { return false }
            _ => ()
        }
    }
    stack.is_empty()
}

I’m on the move right now, so can’t test anything myself. But regex might be the culprit here, that has slow compile times as well. I was considering at some point to replace it with a faster (to compile) implementation, maybe I should do that.

@chezwicker would you mind trying if you get a timeout if you replace regex with regex-lite?

https://crates.io/crates/regex-lite

Then I get the error you mentioned:

image

Oh, so sorry, brain malfunction on my part. that’s not included in the runner :sweat_smile: I might just run with the assumption it’s the regex crate, others had problems as well.

@chezwicker I redeployed the test runner with regex replaced by regex-lite.