« first day (2908 days earlier)      last day (585 days later) » 

4:25 AM
@code_dredd I didn't understand what you really want, you are mixing a lot of thing
@roganjosh xd
 
 
1 hour later…
5:38 AM
@roganjosh The max_shift on line 50 is part of a tuple pattern that's inside the parameter list of a closure, so it defines a new variable within the closure's scope that's bound to the second value of a 2-tuple (pair) that the closure receives as its first argument.
@roganjosh The max_shift on line 49 is part of a tuple pattern that's the left-hand side of a let statement, so it defines a new variable within the scope of the if block that begins on line 48 in function try_advance_departure_time, and it's bound to the second value of a 2-tuple that's returned by the let statement's right-hand side expression.
 
 
1 hour later…
7:00 AM
@Stargateur I don't think I mixed a lot of things. My 2nd post was to clarify an inaccuracy in the first. To recap, I'm writing tests for a Rocket app that requires CLI args and I was asking how to programmatically insert CLI args to the environment so that std::env::args() would retrieve them —if it's even possible at all.
 
@code_dredd there is two thing, integration test should be done with tool extern to rust, internal test you should not rely on argv to run them, and so this mean you are at a point where using a global singleton hurt your code
I mainly guess cause as I said you didn't give a lot of info
 
@Stargateur I think there might be a language barrier here or something. I know what I'm doing, it's in line with the Rocket docs on testing, there're no singletons, etc. Respectfully, I don't want to spend time in a red-herring.
I'm just checking if there's a way to insert CLI args into the environment, but programmatically.
 
and I'm telling you it's depend on what you are doing, as a generally answer then no it's not possible to INSERT args
 
_there're no singletons_ => actually, `args()` reads from a singleton, and is in general not modifiable (it would be a thread-safety nightmare, like `setenv` in C).

For a process to have a specific set of `args()`, your best bet is to launch the process with said `args()`, which can be done programmatically.
 
my point on singleton was about global singleton is a commun simple pattern for carry OPTION in application, but yeah argv in rust is some sort of singleton and is invariable for sane reason
testing and argv doesn't mix well
 
7:55 AM
@FrancisGagné thanks for this. I managed to spot what was going on but was tired yesterday. With the syntax being very different from python, I've been thinking about closures a bit too literally - "well, it must be capturing a name from the enclosing scope, and it is going to be named in that scope so it must be referring to itself" which was totally misguided.
 
8:48 AM
@MatthieuM. Well, if what you say can be done with cargo test, i.e. launching the process directly, then I'm open to suggestions, but you should probably take a quick look at rocket.rs/v0.5-rc/guide/testing because that sounds like a potential hack and I don't want to create problems. I can use env vars defined in my env, but was hoping to do something easier to automate in the test suite.
 
9:26 AM
It's not something I'd do for a unit-test, but for an integration test it's not unusual to have multiple processes, databases, etc... being involved since the point is to test the integration, after all.

I don't think it'd create a problem with Rocket, but it's a lot more involved, certainly.

If I were in your shoes, I'd refactor the application so that `args()` or environment variables are only parsed at the top-level (`main`, or a helper function called from `main`) and translated into a configuration object immediately. Then in tests, you can simply pass a configuration object that you
 
9:37 AM
rocket make it harder with the Rocket.toml, you will need to do a lot of manual config with api.rocket.rs/v0.5-rc/rocket/struct.Config.html
 
10:12 AM
I already do what has been mentioned. Anyway, thanks for the time, but this is now going kind of off-topic. In any case, thanks again.
 
 
5 hours later…
3:24 PM
It's pretty sad to see that a bad question such as this one can garner equally bad answers so quickly.
Yet another case for stronger and quicker curation.
 
3:46 PM
@E_net4thecommentflagger need more cooks in the kitchen for that
 

« first day (2908 days earlier)      last day (585 days later) »