trap_assert_stderr


Description:

[ Version ( since = "2.16" ) ]
public void trap_assert_stderr (string serrpattern)

Example: Assert stderr:

public static int main (string[] args) {
Test.init (ref args);

Test.add_func ("/valadoc/driver-0.14.x", () => {
Test.trap_subprocess ("/valadoc/driver-0.14.x/subprocess", 0, 0);
Test.trap_assert_passed ();

// Assert that the stderr output matches the pattern:
// See GLib.PatternSpec for details
Test.trap_assert_stderr ("*error:*");
});

Test.add_func ("/valadoc/driver-0.14.x/subprocess", () => {
stderr.printf ("error: unexpected token: ==\n");
});

Test.run ();
return 0;
}

valac --pkg glib-2.0 GLib.Test.trap_assert_stderr.vala

./GLib.Test.trap_assert_stderr --verbose


Namespace: GLib.Test
Package: glib-2.0