about summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
* Removed help->usage when not used in testsJames Booth2013-12-171-15/+0
* Added tests for "/account set muc" and "/account set nick"James Booth2013-12-174-2/+102
* Added tests for "/account set password"James Booth2013-12-174-1/+51
* Added tests for "/account set resource"James Booth2013-12-173-0/+45
* Added tests for "/account set server"James Booth2013-12-174-1/+50
* Added validation tests for "/account set" and "/account set jid"James Booth2013-12-164-46/+220
* Use expect_any when testing something else in cmd_account testsJames Booth2013-12-161-7/+7
* Added tests for "/account rename"James Booth2013-12-164-6/+99
* Added tests for "/account disable"James Booth2013-12-154-0/+73
* Added tests for "/account enable"James Booth2013-12-154-0/+73
* Test "/account add" shows message on successJames Booth2013-12-153-0/+18
* Test "/account add <account>" adds accountJames Booth2013-12-154-3/+24
* Test "/account add" with missing argJames Booth2013-12-153-0/+16
* Test "/account show <account>" when account existsJames Booth2013-12-153-1/+22
* Test "/account show" when no account does not existJames Booth2013-12-153-0/+19
* Added "/account show" test when no account suppliedJames Booth2013-12-153-1/+17
* Test "/account list"James Booth2013-12-154-2/+32
* Added cmd_account testJames Booth2013-12-155-1/+62
* Test account free'd after connectJames Booth2013-12-155-2/+39
* Added tests for connecting with accountJames Booth2013-12-154-1/+35
* Added test for message when connecting via accountJames Booth2013-12-153-0/+28
* Added ask for password test when connecting with an accountJames Booth2013-12-154-0/+29
* Tests lowercasing argument on cmd_connectJames Booth2013-12-154-12/+39
* Moved fulljid logic to accountsJames Booth2013-12-154-6/+16
* Ignore arguments that are not part of testJames Booth2013-12-151-10/+10
* Added mock log moduleJames Booth2013-12-156-2/+127
* Moved _ask_password to UI moduleJames Booth2013-12-159-43/+49
* Check expected arg to account_get_account in cmd_rooms testJames Booth2013-12-152-0/+2
* Added cmd_connect testsJames Booth2013-12-156-5/+95
* Seperated command functions into moduleJames Booth2013-12-157-2492/+2566
* Mocked account preferences and tested cmd_roomsJames Booth2013-12-147-9/+198
* Removed commented setion from Makefile.amJames Booth2013-12-141-22/+0
* Tidied Makefile.amJames Booth2013-12-141-2/+4
* Removed debug from testsJames Booth2013-12-142-6/+5
* Added roster_list tests to cmockaJames Booth2013-12-144-93/+140
* Added parser tests to cmockaJames Booth2013-12-144-180/+221
* Added history and jid tests to cmockaJames Booth2013-12-146-159/+198
* Added missing filesJames Booth2013-12-146-0/+516
* Moved autocomplete tests to cmockaJames Booth2013-12-144-49/+48
* Moved common tests to cmockaJames Booth2013-12-145-121/+110
* Added simple mock test, refactored rosterJames Booth2013-12-1430-582/+703
* Merge branch 'master' into refactorJames Booth2013-12-101-0/+49
|\
| * Implemented autocomplete for /account command <setting> parameterJames Booth2013-12-101-0/+49
* | Merge branch 'master' into refactorJames Booth2013-12-103-53/+22
|\|
| * Added comments to autocomplete.hJames Booth2013-12-101-1/+7
| * Tidy autocomplete.hJames Booth2013-12-091-1/+7
| * Removed unused boolean result from autocomplete add and removeJames Booth2013-12-093-45/+8
| * Removed unused prototypes from autocomplete.hJames Booth2013-12-091-6/+0
* | Merge branch 'master' into refactorJames Booth2013-12-083-9/+46
|\|
| * Added clear command to /account for password clearingJames Booth2013-12-083-9/+46
0d407a967d25d793b6a9db56ffd7a03727'>166e3c0d ^
aa088845 ^
48e40252 ^






614ea44b ^
de92036d ^
13ba3def ^

5aa38b52 ^
13ba3def ^
fc4a98dc ^

13ba3def ^
1b76245c ^
13ba3def ^

5aa38b52 ^





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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
                            

                                          

                                             
        
                                        
                                        
                                       
               
                                    
                                                                                                                                            









                                                  
                                                                                                                                                                

          



                                                






                                                                   





                                
                                              
                     



                                                      



        
                                                                                      
                                      

                                 


                                                      






                                             
                                  
                                       
            
                                    
                                                                                                                                          

          






                                                  
                                                                                                                                                             

          
                                              
                                                                                                                                                                                





                                                
                                                      






                                                                   
                                              
                                                            

                   
                                    
                                                  

                                                                                                                           
                  
                                                                       

        





                                             
//: Dead simple persistence.
//:   'restore' - reads string from a file
//:   'save' - writes string to a file

:(before "End Primitive Recipe Declarations")
RESTORE,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "restore", RESTORE);
:(before "End Primitive Recipe Checks")
case RESTORE: {
  if (SIZE(inst.ingredients) != 1) {
    raise << maybe(get(Recipe, r).name) << "'restore' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end();
    break;
  }
  string filename;
  if (is_literal_string(inst.ingredients.at(0))) {
    ;
  }
  else if (is_mu_string(inst.ingredients.at(0))) {
    ;
  }
  else {
    raise << maybe(get(Recipe, r).name) << "first ingredient of 'restore' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case RESTORE: {
  string filename;
  if (is_literal_string(current_instruction().ingredients.at(0))) {
    filename = current_instruction().ingredients.at(0).name;
  }
  else if (is_mu_string(current_instruction().ingredients.at(0))) {
    filename = read_mu_string(ingredients.at(0).at(0));
  }
  if (Current_scenario) {
    // do nothing in tests
    products.resize(1);
    products.at(0).push_back(0);
    break;
  }
  string contents = slurp("lesson/"+filename);
  products.resize(1);
  if (contents.empty())
    products.at(0).push_back(0);
  else
    products.at(0).push_back(new_mu_string(contents));
  break;
}

:(code)
// http://cpp.indi.frih.net/blog/2014/09/how-to-read-an-entire-file-into-memory-in-cpp
string slurp(const string& filename) {
  ifstream fin(filename.c_str());
  fin.peek();
  if (!fin) return "";  // don't bother checking errno
  ostringstream result;
  result << fin.rdbuf();
  fin.close();
  return result.str();
}

:(before "End Primitive Recipe Declarations")
SAVE,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "save", SAVE);
:(before "End Primitive Recipe Checks")
case SAVE: {
  if (SIZE(inst.ingredients) != 2) {
    raise << maybe(get(Recipe, r).name) << "'save' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end();
    break;
  }
  if (is_literal_string(inst.ingredients.at(0))) {
    ;
  }
  else if (is_mu_string(inst.ingredients.at(0))) {
    ;
  }
  else {
    raise << maybe(get(Recipe, r).name) << "first ingredient of 'save' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end();
    break;
  }
  if (!is_mu_string(inst.ingredients.at(1))) {
    raise << maybe(get(Recipe, r).name) << "second ingredient of 'save' should be an address:array:character, but got '" << to_string(inst.ingredients.at(1)) << "'\n" << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case SAVE: {
  if (Current_scenario) break;  // do nothing in tests
  string filename;
  if (is_literal_string(current_instruction().ingredients.at(0))) {
    filename = current_instruction().ingredients.at(0).name;
  }
  else if (is_mu_string(current_instruction().ingredients.at(0))) {
    filename = read_mu_string(ingredients.at(0).at(0));
  }
  ofstream fout(("lesson/"+filename).c_str());
  string contents = read_mu_string(ingredients.at(1).at(0));
  fout << contents;
  fout.close();
  if (!exists("lesson/.git")) break;
  // bug in git: git diff -q messes up --exit-code
  // explicitly say '--all' for git 1.9
  int status = system("cd lesson; git add --all .; git diff HEAD --exit-code >/dev/null || git commit -a -m . >/dev/null");
  if (status != 0)
    raise << "error in commit: contents " << contents << '\n' << end();
  break;
}

:(code)
bool exists(const string& filename) {
  struct stat dummy;
  return 0 == stat(filename.c_str(), &dummy);
}