Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

process::ExitStatus should have some kind of constructor #32713

Closed

Description

@nrc

Because ExitStatus has a private field it is impossible to create one in user code, one must actually execute a process. This prevents testing/mocking. My use case is that I have some function which runs a process and generates data, however, for testing I want to mock the test run and just return a success exit status and some data. I can't do that because I can't create my own ExitStatus objects.

At the least there should be a way to create a success ExitStatus. Preferably, there would be a way to create various fail statuses too.

Activity

  1. frewsxcv commented on Apr 4, 2016

    @frewsxcv
    Contributor

    Should the constructor just take an i32?

  2. alexcrichton commented on Apr 4, 2016

    @alexcrichton
    Member

    I've also wanted a basically "raw constructor" in the past. I'd be fine adding some std::os extensions which allow construction from a c_int or DWORD (i32 and u32)

  3. jirutka commented on Apr 26, 2016

    @jirutka

    +1
    I’d like to extend Command, but I cannot reuse Output for return value because I can’t construct ExitStatus. :(

  4. alexcrichton commented on Apr 26, 2016

    @alexcrichton
    Member

    I've opened a PR for this over at #33224

  5. jirutka commented on Apr 26, 2016

    @jirutka

    Great, thanks! 👍

  6. added 2 commits that reference this issue on May 9, 2016
  7. added a commit that references this issue on May 9, 2016
  8. added a commit that references this issue on May 9, 2016
  9. added
    T-libs-api
    B-unstable
    on Jun 21, 2016
  10. joelself commented on Jul 6, 2016

    @joelself

    This would help n00bs like me who start out by copying the example code and tweaking it:

    let output = Command::new("sh")
                         .arg("-c")
                         .arg("echo hello")
                         .output()
                         .unwrap_or_else(|e| { panic!("failed to execute process: {}", e) });

    This example is a special case that only happens to work if the unwrap_or_else contains a panic! or something else that immediately exits. Otherwise you need to create your own Output struct to return which is currently impossible.

  11. added
    final-comment-period
    and removed on Jul 11, 2016
  12. alexcrichton commented on Jul 13, 2016

    @alexcrichton
    Member

    🔔 This issue is now entering a cycle-long final comment period for stabilization 🔔

  13. alexcrichton commented on Aug 11, 2016

    @alexcrichton
    Member

    Discussed recently, the libs team decided to stabilize.

  14. added a commit that references this issue on Aug 18, 2016
    7f38beb
  15. added a commit that references this issue on Aug 20, 2016
    99867ee
  16. added a commit that references this issue on Aug 23, 2016
    4ce3c86
  17. added a commit that references this issue on Sep 27, 2016
    1076a3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableT-libs-apifinal-comment-period

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions