import dshould; import std.conv: octal; Path root = createTempPath(); scope(exit) root.remove(); // Create simple test script that will print its arguments root.join("test-script").writeFile( "#!/usr/bin/env bash\necho \"$@\";"); // Add permission to run this script root.join("test-script").setAttributes(octal!755); // Run test script without args auto status1 = root.join("test-script").execute; status1.status.should.be(0); status1.output.should.equal("\n"); auto status2 = root.join("test-script").execute(["hello", "world"]); status2.status.should.be(0); status2.output.should.equal("hello world\n"); auto status3 = root.join("test-script").execute(["hello", "world\nplus"]); status3.status.should.be(0); status3.output.should.equal("hello world\nplus\n"); auto status4 = root.join("test-script").execute( ["hello", "world"], null, root); status4.status.should.be(0); status4.output.should.equal("hello world\n");
Execute the file pointed by path * * Params: * args = arguments to be passed to program * env = associative array that represent environment variables * to be passed to program pointed by path * workDir = Working directory for new process. * config = Parameters for process creation. * See See std.process.Config * maxOutput = Max bytes of output to be captured * Returns: * An std.typecons.Tuple!(int, "status", string, "output").