Test.GtkWriter.vala.c
[app.Builder.js] / Test.GtkWriter.vala
1 /**
2  * Test the writer code...
3
4
5 */
6
7
8 void diff(string original, string data)
9 {
10         
11         FileUtils.set_contents("/tmp/test.out",data);
12         string[] spawn_args = {"diff", "-w" , "-u", original, "/tmp/test.out" };
13         
14         
15         string[] spawn_env = Environ.get ();
16         int ls_status;
17         Process.spawn_sync ("/",
18                                                         spawn_args,
19                                                         spawn_env,
20                                                         SpawnFlags.SEARCH_PATH,
21                                                         null,
22                                                         null,
23                                                         null,
24                                                         out ls_status);
25          
26
27 }
28
29 void testBuilderFile(string name, string test)
30 {
31         var dir = "/home/alan/gitlive/app.Builder.js/Builder4"; 
32         var proj = new Project.Gtk(dir );
33         proj.scanDirs();
34         //print(proj.toJSON(true));
35         //print("\ndone\n");
36         var tf = proj.files.get(dir + "/" + name + ".bjs");
37         tf.loadItems();
38         switch(test) {
39                 case "JSON":
40                         diff(dir + "/" + name + ".bjs", tf.toJsonString());
41                         return;
42                 case "JS":
43                         diff(dir + "/" + name + ".js", tf.toSource());
44                         return;
45                 case "VALA":
46                         diff(dir + "/" + name + ".vala", tf.toValaSource(false));
47                         return;
48         }
49         print("invalid test?\n");
50 }
51
52 public static int main () {
53     new JsRender.Lang_Class();
54         GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); 
55
56
57         //testBuilderFile("Editor", "JSON");
58         //testBuilderFile("Editor", "JS");
59         testBuilderFile("Editor", "VALA");
60
61     
62         
63         return 0;
64 }