about summary refs log tree commit diff stats
path: root/relayout
blob: 8ea48920a3bf4ec9127bf453db7795607c52992a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Helper to change the numerical prefixes across the repo, say if you want to
# create room between 023 and 024, and so on.
#
# Assumes there's only ever one file with any numeric prefix. If you move
# 003trace.test.cc you might need to do some manual patch-up.

set -e

if [[ $# -eq 0 && `git diff HEAD |wc -l` -gt 0 ]]
then
  echo "Uncommitted changes"
  exit
fi

if [[ $# -gt 0 ]] # dry run
then
  git() {
    echo $*
  }
fi

#

index=0
ls [0-9]* |grep -v "trace.test" |sort -n |
  while read file
  do
    while [[ $file != `printf "%03d" $index`* ]]
    do
      echo
      index=$(($index+1))
    done
    echo $file
    index=$(($index+1))
  done > .layout

vim -c "set nu" .layout

#

root() {
  echo $1 |sed 's/^[0-9]*//'
}

index=0
cat .layout |
  while read file
  do
    if [ ! -z $file ]
    then
      newfile=`printf "%03d" $index``root $file`
      if [[ $newfile != $file ]]
      then
        echo git mv $file $newfile
        git mv $file $newfile
      fi
    fi
    index=$(($index+1))
  done

rm .layout

# Scenarios considered:
#   Don't redo the layout if Vim exits with error.
en_connecting(void **state) { test_with_connection_status(JABBER_CONNECTING); } void cmd_join_shows_message_when_disconnected(void **state) { test_with_connection_status(JABBER_DISCONNECTED); } void cmd_join_shows_message_when_undefined(void **state) { test_with_connection_status(JABBER_UNDEFINED); } void cmd_join_shows_error_message_when_invalid_room_jid(void **state) { gchar *args[] = { "//@@/", NULL }; will_return(jabber_get_connection_status, JABBER_CONNECTED); expect_cons_show_error("Specified room has incorrect format."); expect_cons_show(""); gboolean result = cmd_join(NULL, CMD_JOIN, args); assert_true(result); } void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) { char *account_name = "an_account"; char *room = "room"; char *nick = "bob"; char *account_service = "conference.server.org"; char *expected_room = "room@conference.server.org"; gchar *args[] = { room, "nick", nick, NULL }; ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_account_name, account_name); expect_string(accounts_get_account, name, account_name); will_return(accounts_get_account, account); expect_string(presence_join_room, room, expected_room); expect_string(presence_join_room, nick, nick); expect_value(presence_join_room, passwd, NULL); gboolean result = cmd_join(NULL, CMD_JOIN, args); assert_true(result); } void cmd_join_uses_supplied_nick(void **state) { char *account_name = "an_account"; char *room = "room@conf.server.org"; char *nick = "bob"; gchar *args[] = { room, "nick", nick, NULL }; ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_account_name, account_name); expect_string(accounts_get_account, name, account_name); will_return(accounts_get_account, account); expect_string(presence_join_room, room, room); expect_string(presence_join_room, nick, nick); expect_value(presence_join_room, passwd, NULL); gboolean result = cmd_join(NULL, CMD_JOIN, args); assert_true(result); } void cmd_join_uses_account_nick_when_not_supplied(void **state) { char *account_name = "an_account"; char *room = "room2@conf.server.org"; char *account_nick = "a_nick"; gchar *args[] = { room, NULL }; ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_account_name, account_name); expect_string(accounts_get_account, name, account_name); will_return(accounts_get_account, account); expect_string(presence_join_room, room, room); expect_string(presence_join_room, nick, account_nick); expect_value(presence_join_room, passwd, NULL); gboolean result = cmd_join(NULL, CMD_JOIN, args); assert_true(result); } void cmd_join_uses_password_when_supplied(void **state) { char *account_name = "an_account"; char *room = "room"; char *password = "a_password"; char *account_nick = "a_nick"; char *account_service = "a_service"; char *expected_room = "room@a_service"; gchar *args[] = { room, "password", password, NULL }; ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_account_name, account_name); expect_string(accounts_get_account, name, account_name); will_return(accounts_get_account, account); expect_string(presence_join_room, room, expected_room); expect_string(presence_join_room, nick, account_nick); expect_value(presence_join_room, passwd, password); gboolean result = cmd_join(NULL, CMD_JOIN, args); assert_true(result); }