Skip to content

Commit

Permalink
#164 WD_CHANGE_SUCCESS_MSG
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis committed Nov 18, 2024
1 parent 3eef178 commit 3f271dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ void handle_success(void) {
log_info("\nExecuting CHANGE_SUCCESS_CMD:");
log_info(" %s", cfg->change_success_cmd);

const struct STable *env = stable_init(5, 5, false);
stable_put(env, "WD_MESSAGE", deltas_brief);
const struct STable *env = stable_init(1, 1, false);
stable_put(env, "WD_CHANGE_SUCCESS_MSG", deltas_brief);
spawn_sh_cmd(cfg->change_success_cmd, env);
stable_free(env);
}
Expand Down
6 changes: 6 additions & 0 deletions tst/asserts.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "head.h"
#include "marshalling.h"
#include "slist.h"
#include "stable.h"
#include "util.h"

#define assert_string_equal_nn(a, b) \
Expand Down Expand Up @@ -75,5 +76,10 @@ void _assert_log(enum LogThreshold t, const char* s, const char * const file, co
void _assert_logs_empty(const char * const file, const int line);
#define assert_logs_empty() _assert_logs_empty(__FILE__, __LINE__)

int expect_stable_equal(const LargestIntegralType value,
const LargestIntegralType check_value_data) {
return stable_equal((struct STable*)value, (struct STable*)check_value_data, NULL);
}

#endif // ASSERTS_H

8 changes: 7 additions & 1 deletion tst/tst-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "log.h"
#include "mode.h"
#include "slist.h"
#include "stable.h"
#include "wlr-output-management-unstable-v1.h"

struct SList *order_heads(struct SList *order_name_desc, struct SList *heads);
Expand Down Expand Up @@ -644,8 +645,11 @@ void handle_success__change_success_cmd(void **state) {
cfg->change_success_cmd = strdup("echo \"hi from way-displays\"");
deltas_brief = strdup("DP-1: enabled\n mode: xx->yy");

const struct STable *env = stable_init(1, 1, false);
stable_put(env, "WD_CHANGE_SUCCESS_MSG", deltas_brief);

expect_string(__wrap_spawn_sh_cmd, command, cfg->change_success_cmd);
expect_string(__wrap_spawn_sh_cmd, message, deltas_brief);
expect_check(__wrap_spawn_sh_cmd, message, expect_stable_equal, env);

handle_success();

Expand All @@ -654,6 +658,8 @@ void handle_success__change_success_cmd(void **state) {
assert_log(INFO, "\nExecuting CHANGE_SUCCESS_CMD:\n"
" echo \"hi from way-displays\"\n"
"\nChanges successful\n");

stable_free(env);
}

void handle_success__ok(void **state) {
Expand Down

0 comments on commit 3f271dd

Please sign in to comment.