flok 0.0.40 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/drivers/chrome/src/dispatch.js +7 -2
- data/app/kern/dispatch.js +10 -1
- data/app/kern/mod/event.js +9 -0
- data/app/kern/pagers/pg_mem.js +21 -0
- data/app/kern/pagers/pg_net_sim.js +44 -0
- data/app/kern/pagers/pg_spec.js +23 -0
- data/app/kern/services/vm.rb +60 -64
- data/bin/flok +44 -23
- data/docs/callout.md +1 -1
- data/docs/client_api.md +5 -2
- data/docs/config_yml.md +41 -0
- data/docs/controllers.md +4 -0
- data/docs/datatypes.md +5 -2
- data/docs/debug_server.md +2 -0
- data/docs/dispatch.md +8 -3
- data/docs/known_issues.md +6 -0
- data/docs/mod/event.md +25 -20
- data/docs/mod/persist.md +1 -1
- data/docs/mod/speech.md +12 -0
- data/docs/project.md +2 -2
- data/docs/services/vm.md +46 -17
- data/docs/services/vm/pagers.md +22 -2
- data/lib/flok/build.rb +0 -4
- data/lib/flok/user_compiler.rb +123 -47
- data/lib/flok/user_compiler_templates/ctable.js.erb +39 -1
- data/lib/flok/version.rb +1 -1
- data/spec/env/global.rb +1 -0
- data/spec/env/kern.rb +5 -1
- data/spec/etc/cli_spec.rb +337 -322
- data/spec/etc/service_compiler/config0.rb +1 -1
- data/spec/etc/service_compiler/config0b.rb +1 -0
- data/spec/etc/services_compiler_spec.rb +29 -29
- data/spec/etc/user_compiler/controller0b.rb +9 -0
- data/spec/etc/user_compiler/controller0timer.rb +16 -0
- data/spec/etc/user_compiler_spec.rb +24 -1
- data/spec/iface/driver/dispatch_spec.rb +8 -2
- data/spec/iface/driver/persist_spec.rb +11 -0
- data/spec/kern/assets/controller0defer.rb +18 -0
- data/spec/kern/assets/controller0defer0.rb +13 -0
- data/spec/kern/assets/controller0defer2.rb +17 -0
- data/spec/kern/assets/global_on_entry.rb +8 -0
- data/spec/kern/assets/global_on_entry2.rb +16 -0
- data/spec/kern/assets/global_on_entry3.rb +17 -0
- data/spec/kern/assets/global_on_entry4.rb +12 -0
- data/spec/kern/assets/interval.rb +29 -0
- data/spec/kern/assets/interval2.rb +33 -0
- data/spec/kern/assets/interval3.rb +39 -0
- data/spec/kern/assets/service1.rb +4 -1
- data/spec/kern/assets/service_controller1.rb +11 -0
- data/spec/kern/assets/specimin/controller0.rb +74 -0
- data/spec/kern/assets/vm/config5.rb +20 -0
- data/spec/kern/assets/vm/config6.rb +20 -0
- data/spec/kern/assets/vm/controller10.rb +1 -1
- data/spec/kern/assets/vm/controller11.rb +1 -1
- data/spec/kern/assets/vm/controller12.rb +1 -1
- data/spec/kern/assets/vm/controller13.rb +1 -1
- data/spec/kern/assets/vm/controller16b.rb +28 -0
- data/spec/kern/assets/vm/controller18.rb +1 -1
- data/spec/kern/assets/vm/controller21.rb +1 -1
- data/spec/kern/assets/vm/controller22.rb +8 -0
- data/spec/kern/assets/vm/controller_exc_ewatch.rb +1 -0
- data/spec/kern/assets/vm/controller_exc_ewatch2.rb +30 -0
- data/spec/kern/assets/vm/controller_exc_ewatch3.rb +16 -0
- data/spec/kern/assets/vm/controller_exc_ewatch4.rb +16 -0
- data/spec/kern/assets/vm/macros/copy_page_c.rb +1 -0
- data/spec/kern/assets/vm/macros/copy_page_ch.rb +25 -0
- data/spec/kern/assets/vm/macros/entry_del_c.rb +1 -0
- data/spec/kern/assets/vm/macros/entry_del_ch.rb +20 -0
- data/spec/kern/assets/vm/macros/entry_insert_c.rb +1 -0
- data/spec/kern/assets/vm/macros/entry_insert_ch.rb +23 -0
- data/spec/kern/assets/vm/macros/entry_mutable_c.rb +8 -7
- data/spec/kern/assets/vm/macros/entry_mutable_ch.rb +34 -0
- data/spec/kern/assets/vm/macros/new_page_c.rb +1 -1
- data/spec/kern/assets/vm/macros/new_page_c2.rb +1 -1
- data/spec/kern/assets/vm/macros/new_page_ch.rb +7 -0
- data/spec/kern/assets/vm/pg_mem/config.rb +10 -0
- data/spec/kern/assets/vm/pg_mem/config1.rb +10 -0
- data/spec/kern/assets/vm/pg_mem/config2.rb +10 -0
- data/spec/kern/assets/vm/pg_mem/config3.rb +15 -0
- data/spec/kern/assets/vm/pg_mem/write.rb +23 -0
- data/spec/kern/assets/vm/pg_mem/write2.rb +38 -0
- data/spec/kern/assets/vm/pg_net_sim/config.rb +10 -0
- data/spec/kern/assets/vm/pg_net_sim/nothing.rb +12 -0
- data/spec/kern/assets/vm/pg_net_sim/pages.json +1 -0
- data/spec/kern/assets/vm/pg_net_sim/watch.rb +18 -0
- data/spec/kern/callout_spec.rb +1 -1
- data/spec/kern/controller_macro_spec.rb +153 -20
- data/spec/kern/controller_spec.rb +232 -1
- data/spec/kern/debug_ui_spec.rb +235 -235
- data/spec/kern/event_spec.rb +112 -0
- data/spec/kern/service_controller_spec.rb +14 -2
- data/spec/kern/vm_service_mem_pagers_spec.rb +117 -0
- data/spec/kern/vm_service_net_sim_pager_spec.rb +97 -0
- data/spec/kern/vm_service_spec.rb +304 -17
- data/spec/kern/vm_service_spec2.rb +39 -0
- metadata +88 -6
- data/app/kern/pagers/mem_pager.js +0 -2
- data/app/kern/pagers/pg_spec0.js +0 -20
- data/lib/flok/project_template/Guardfile +0 -7
- data/lib/flok/project_template/config/config.yml +0 -1
|
@@ -5,11 +5,40 @@ ctable = {
|
|
|
5
5
|
<% c._services.each do |s| %>
|
|
6
6
|
<%= s %>_on_connect(__base__);
|
|
7
7
|
<% end %>
|
|
8
|
+
|
|
9
|
+
//Register this controller for every single interval timer *now*
|
|
10
|
+
<% actions_for_controller(c.name).each do |a| %>
|
|
11
|
+
<% a.every_handlers.each do |e| %>
|
|
12
|
+
reg_interval(__base__, "<%= e[:name] %>", <%= e[:ticks] %>);
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
//Controller information, includes action, etc. (controller_info)
|
|
18
|
+
var __info__ = tel_deref(__base__);
|
|
19
|
+
|
|
20
|
+
//The 'context' which is user-defined
|
|
21
|
+
var context = __info__.context;
|
|
22
|
+
|
|
23
|
+
//Call global on entry
|
|
24
|
+
<%= c._on_entry %>
|
|
8
25
|
},
|
|
9
26
|
__dealloc__: function(__base__) {
|
|
27
|
+
var __info__ = tel_deref(__base__);
|
|
28
|
+
|
|
29
|
+
//Recursively call dealloc
|
|
30
|
+
for (var i = 0; i < __info__.embeds.length; ++i) {
|
|
31
|
+
for (var x = 0; x < __info__.embeds[i].length; ++x) {
|
|
32
|
+
tel_deref(__info__.embeds[i][x]).cte.__dealloc__(__info__.embeds[i][x]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
10
36
|
<% c._services.each do |s| %>
|
|
11
37
|
<%= s %>_on_disconnect(__base__);
|
|
12
38
|
<% end %>
|
|
39
|
+
|
|
40
|
+
dereg_evt(__base__);
|
|
41
|
+
tel_del(__base__);
|
|
13
42
|
},
|
|
14
43
|
name: '<%= c.name %>',
|
|
15
44
|
root_view: '<%= c.name %>',
|
|
@@ -23,6 +52,7 @@ ctable = {
|
|
|
23
52
|
|
|
24
53
|
//The 'context' which is user-defined
|
|
25
54
|
var context = __info__.context;
|
|
55
|
+
|
|
26
56
|
<%= a.on_entry_src.strip %>
|
|
27
57
|
},
|
|
28
58
|
handlers: {
|
|
@@ -34,7 +64,15 @@ ctable = {
|
|
|
34
64
|
<%= e[:src] %>
|
|
35
65
|
},
|
|
36
66
|
<% end %>
|
|
37
|
-
|
|
67
|
+
<% a.every_handlers.each do |e| %>
|
|
68
|
+
"<%= e[:name] %>": function(__base__, ename, info) {
|
|
69
|
+
var __info__ = tel_deref(__base__);
|
|
70
|
+
var context = __info__.context;
|
|
71
|
+
|
|
72
|
+
<%= e[:src] %>
|
|
73
|
+
},
|
|
74
|
+
<% end %>
|
|
75
|
+
},
|
|
38
76
|
},
|
|
39
77
|
<% end %>
|
|
40
78
|
},
|
data/lib/flok/version.rb
CHANGED
data/spec/env/global.rb
CHANGED
data/spec/env/kern.rb
CHANGED
|
@@ -121,7 +121,7 @@ shared_context "kern" do
|
|
|
121
121
|
#There may be a lot going on and you're only interested in a part.
|
|
122
122
|
#If priority is nil, it won't matter what the priority is, useful for checking exceptions
|
|
123
123
|
#for non-existant messages
|
|
124
|
-
def ignore_up_to msg_name, priority=nil
|
|
124
|
+
def ignore_up_to msg_name, priority=nil, &block
|
|
125
125
|
@did_get = []
|
|
126
126
|
|
|
127
127
|
loop do
|
|
@@ -150,6 +150,10 @@ shared_context "kern" do
|
|
|
150
150
|
raise "Found the message #{msg_name.inspect} while calling ignore_up_to... but it's the wrong priority: #{@cp}, should be #{priority}" if @cp != priority
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
+
if block
|
|
154
|
+
next unless block.call(args)
|
|
155
|
+
end
|
|
156
|
+
|
|
153
157
|
#Unshift everything in reverse order, we are only peeking here...
|
|
154
158
|
args.reverse.each do |a|
|
|
155
159
|
@cq.unshift a
|
data/spec/etc/cli_spec.rb
CHANGED
|
@@ -12,9 +12,7 @@ require 'securerandom'
|
|
|
12
12
|
#Execute flok binary
|
|
13
13
|
def flok args
|
|
14
14
|
#Execute
|
|
15
|
-
|
|
16
|
-
ENV['RUBYOPT'] = ""
|
|
17
|
-
res = system("bundle exec flok #{args}")
|
|
15
|
+
res = system("bundle exec #{$flok_bin_path} #{args}")
|
|
18
16
|
raise "Could not execute bundle exec flok #{args.inspect}" unless res
|
|
19
17
|
end
|
|
20
18
|
|
|
@@ -25,126 +23,165 @@ def flok_new
|
|
|
25
23
|
#This isn't done with flok() because we don't have a project yet, ergo, no Gemfile
|
|
26
24
|
#But it's ok because it's *this* development version because we installed a copy of
|
|
27
25
|
#it before this spec ran in before(:each)
|
|
28
|
-
system("
|
|
26
|
+
system("#{$flok_bin_path} new test")
|
|
29
27
|
|
|
30
28
|
Dir.chdir "test" do
|
|
31
|
-
|
|
29
|
+
#We need to modify the gemfile to include a path to this gem project
|
|
30
|
+
#so that bundler will set everything up for us as if this was a real gem
|
|
31
|
+
File.write "Gemfile", %{
|
|
32
|
+
#This gemfile uses this project's path
|
|
33
|
+
source 'https://rubygems.org'
|
|
34
|
+
|
|
35
|
+
gem 'flok', :path => "#{File.join(File.dirname(__FILE__), "../../")}"
|
|
36
|
+
}
|
|
32
37
|
yield
|
|
33
38
|
end
|
|
34
39
|
end
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
RSpec.describe "CLI" do
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
it "Can be executed via bundle exec" do flok_new do
|
|
44
|
+
flok "build"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#When this sets FLOK_CONFIG, the defines is added to the project config.yml
|
|
49
|
+
#to show spec_helper_defines_spec_test. This text should show up in the final
|
|
50
|
+
#source code
|
|
51
|
+
it "Does set the FLOK_CONFIG to the correct file based on PLATFORM" do
|
|
52
|
+
flok_new do
|
|
53
|
+
#Set spec_test in project configuration
|
|
54
|
+
config_yml = YAML.load_file("./config/platforms/#{ENV['PLATFORM']}/config.yml")
|
|
55
|
+
config_yml["DEBUG"]["defines"] = ["spec_test"]
|
|
56
|
+
File.write("./config/platforms/#{ENV['PLATFORM']}/config.yml", config_yml.to_yaml)
|
|
57
|
+
|
|
58
|
+
#Now commit a build
|
|
59
|
+
flok "build"
|
|
60
|
+
|
|
61
|
+
#Now read the application_user file, it should contain the string located in `./app/kern/spec_helper.js`
|
|
62
|
+
#that will only show if the correct defines is set
|
|
63
|
+
application_user = File.read("./products/#{ENV['PLATFORM']}/application_user.js")
|
|
64
|
+
expect(application_user).to include("spec_helper_defines_spec_test")
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "Can create a new project with correct directories" do
|
|
69
|
+
flok_new do
|
|
70
|
+
#Should include all entities in the project template with the exception
|
|
71
|
+
#of erb extenseded entities (which will still be included, but they each
|
|
72
|
+
#will not have the erb ending
|
|
73
|
+
template_nodes = nil
|
|
74
|
+
Dir.chdir File.join(File.dirname(__FILE__), "../../lib/flok/project_template") do
|
|
75
|
+
template_nodes = Dir["**/*"].map{|e| e.gsub(/\.erb$/i, "")}
|
|
76
|
+
end
|
|
77
|
+
new_proj_nodes = Dir["**/*"]
|
|
78
|
+
expect(new_proj_nodes.sort).to eq(template_nodes.sort)
|
|
79
|
+
|
|
80
|
+
expect(files).to include("Gemfile")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "Can build a project with every type of platform" do
|
|
85
|
+
platform = ENV['PLATFORM']
|
|
86
|
+
flok_new do
|
|
87
|
+
#Build a new project
|
|
88
|
+
flok "build"
|
|
89
|
+
|
|
90
|
+
#Check it's products directory
|
|
91
|
+
expect(dirs).to include "products"
|
|
92
|
+
Dir.chdir "products" do
|
|
93
|
+
#Has a platform folder
|
|
94
|
+
expect(dirs).to include platform
|
|
95
|
+
Dir.chdir platform do
|
|
96
|
+
#Has an application_user.js file
|
|
97
|
+
expect(files).to include "application_user.js"
|
|
98
|
+
|
|
99
|
+
#The application_user.js contains both the glob/application.js and the glob/user_compiler.js
|
|
100
|
+
glob_application_js = File.read('glob/application.js')
|
|
101
|
+
glob_user_compiler_js = File.read('glob/user_compiler.js')
|
|
102
|
+
application_user_js = File.read('application_user.js')
|
|
103
|
+
expect(application_user_js).to include(glob_application_js)
|
|
104
|
+
expect(application_user_js).to include(glob_user_compiler_js)
|
|
105
|
+
|
|
106
|
+
#Contains the same files as the kernel in the drivers directory
|
|
107
|
+
expect(dirs).to include "drivers"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "Can build a project with a controller file for each platform" do
|
|
114
|
+
#Compile and then return the length of the application_user.js file
|
|
115
|
+
def compile_with_file path=nil
|
|
116
|
+
#Custom controller to test source with
|
|
117
|
+
controller_src = File.read(path) if path
|
|
118
|
+
flok_new do
|
|
119
|
+
File.write "./app/controllers/controller0.rb", controller_src if path
|
|
120
|
+
|
|
121
|
+
#Build a new project
|
|
122
|
+
flok "build"
|
|
123
|
+
|
|
124
|
+
#Check it's products directory
|
|
125
|
+
Dir.chdir "products" do
|
|
126
|
+
#Has a platform folder
|
|
127
|
+
Dir.chdir @platform do
|
|
128
|
+
glob_application_js = File.read('glob/application.js')
|
|
129
|
+
glob_user_compiler_js = File.read('glob/user_compiler.js')
|
|
130
|
+
application_user_js = File.read('application_user.js')
|
|
131
|
+
|
|
132
|
+
return application_user_js.split("\n").count
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
platform = ENV['PLATFORM']
|
|
139
|
+
@platform = platform
|
|
140
|
+
controller_rb = File.read('./spec/etc/user_compiler/controller0.rb')
|
|
141
|
+
|
|
142
|
+
#The file with content should be longer when compiled into the flat application_user.js
|
|
143
|
+
len_with_content = compile_with_file "./spec/etc/user_compiler/controller0.rb"
|
|
144
|
+
len_no_content = compile_with_file
|
|
145
|
+
|
|
146
|
+
expect(len_no_content).to be < len_with_content
|
|
41
147
|
end
|
|
42
148
|
|
|
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
|
-
#expect(files).to include("Gemfile")
|
|
81
|
-
#end
|
|
82
|
-
#end
|
|
83
|
-
|
|
84
|
-
#it "Can build a project with every type of platform" do
|
|
85
|
-
#platform = ENV['PLATFORM']
|
|
86
|
-
#flok_new do
|
|
87
|
-
##Build a new project
|
|
88
|
-
#flok "build"
|
|
89
|
-
|
|
90
|
-
##Check it's products directory
|
|
91
|
-
#expect(dirs).to include "products"
|
|
92
|
-
#Dir.chdir "products" do
|
|
93
|
-
##Has a platform folder
|
|
94
|
-
#expect(dirs).to include platform
|
|
95
|
-
#Dir.chdir platform do
|
|
96
|
-
##Has an application_user.js file
|
|
97
|
-
#expect(files).to include "application_user.js"
|
|
98
|
-
|
|
99
|
-
##The application_user.js contains both the glob/application.js and the glob/user_compiler.js
|
|
100
|
-
#glob_application_js = File.read('glob/application.js')
|
|
101
|
-
#glob_user_compiler_js = File.read('glob/user_compiler.js')
|
|
102
|
-
#application_user_js = File.read('application_user.js')
|
|
103
|
-
#expect(application_user_js).to include(glob_application_js)
|
|
104
|
-
#expect(application_user_js).to include(glob_user_compiler_js)
|
|
105
|
-
|
|
106
|
-
##Contains the same files as the kernel in the drivers directory
|
|
107
|
-
#expect(dirs).to include "drivers"
|
|
108
|
-
#end
|
|
109
|
-
#end
|
|
110
|
-
#end
|
|
111
|
-
#end
|
|
112
|
-
|
|
113
|
-
#it "Can build a project with a controller file for each platform" do
|
|
114
|
-
##Compile and then return the length of the application_user.js file
|
|
115
|
-
#def compile_with_file path=nil
|
|
116
|
-
##Custom controller to test source with
|
|
117
|
-
#controller_src = File.read(path) if path
|
|
118
|
-
#flok_new do
|
|
119
|
-
#File.write "./app/controllers/controller0.rb", controller_src if path
|
|
120
|
-
|
|
121
|
-
##Build a new project
|
|
122
|
-
#flok "build"
|
|
123
|
-
|
|
124
|
-
##Check it's products directory
|
|
125
|
-
#Dir.chdir "products" do
|
|
126
|
-
##Has a platform folder
|
|
127
|
-
#Dir.chdir @platform do
|
|
128
|
-
#glob_application_js = File.read('glob/application.js')
|
|
129
|
-
#glob_user_compiler_js = File.read('glob/user_compiler.js')
|
|
130
|
-
#application_user_js = File.read('application_user.js')
|
|
131
|
-
|
|
132
|
-
#return application_user_js.split("\n").count
|
|
133
|
-
#end
|
|
134
|
-
#end
|
|
135
|
-
#end
|
|
136
|
-
#end
|
|
137
|
-
|
|
138
|
-
#platform = ENV['PLATFORM']
|
|
139
|
-
#@platform = platform
|
|
140
|
-
#controller_rb = File.read('./spec/etc/user_compiler/controller0.rb')
|
|
141
|
-
|
|
142
|
-
##The file with content should be longer when compiled into the flat application_user.js
|
|
143
|
-
#len_with_content = compile_with_file "./spec/etc/user_compiler/controller0.rb"
|
|
144
|
-
#len_no_content = compile_with_file
|
|
145
|
-
|
|
146
|
-
#expect(len_no_content).to be < len_with_content
|
|
147
|
-
#end
|
|
149
|
+
it "Can build a project with a file in ./app/controllers/**/.rb" do
|
|
150
|
+
#Compile and then return the length of the application_user.js file
|
|
151
|
+
def compile_with_file path=nil
|
|
152
|
+
#Custom controller to test source with
|
|
153
|
+
controller_src = File.read(path) if path
|
|
154
|
+
flok_new do
|
|
155
|
+
FileUtils.mkdir_p "./app/controllers/sub"
|
|
156
|
+
File.write "./app/controllers/sub/controller0.rb", controller_src if path
|
|
157
|
+
|
|
158
|
+
#Build a new project
|
|
159
|
+
flok "build"
|
|
160
|
+
|
|
161
|
+
#Check it's products directory
|
|
162
|
+
Dir.chdir "products" do
|
|
163
|
+
#Has a platform folder
|
|
164
|
+
Dir.chdir @platform do
|
|
165
|
+
glob_application_js = File.read('glob/application.js')
|
|
166
|
+
glob_user_compiler_js = File.read('glob/user_compiler.js')
|
|
167
|
+
application_user_js = File.read('application_user.js')
|
|
168
|
+
|
|
169
|
+
return application_user_js.split("\n").count
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
platform = ENV['PLATFORM']
|
|
176
|
+
@platform = platform
|
|
177
|
+
controller_rb = File.read('./spec/etc/user_compiler/controller0.rb')
|
|
178
|
+
|
|
179
|
+
#The file with content should be longer when compiled into the flat application_user.js
|
|
180
|
+
len_with_content = compile_with_file "./spec/etc/user_compiler/controller0.rb"
|
|
181
|
+
len_no_content = compile_with_file
|
|
182
|
+
|
|
183
|
+
expect(len_no_content).to be < len_with_content
|
|
184
|
+
end
|
|
148
185
|
|
|
149
186
|
it "Can build a project with a javascript file for each platform" do
|
|
150
187
|
#Compile and then return the length of the application_user.js file
|
|
@@ -178,213 +215,191 @@ RSpec.describe "CLI" do
|
|
|
178
215
|
expect(len_no_content).to be < len_with_content
|
|
179
216
|
end
|
|
180
217
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
#
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
#
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
##Now add a file
|
|
370
|
-
#File.write "./app/controllers/test2.rb", %{
|
|
371
|
-
#controller "my_controller" do
|
|
372
|
-
#action "my_action" do
|
|
373
|
-
#on_entry %{
|
|
374
|
-
#}
|
|
375
|
-
#end
|
|
376
|
-
#end
|
|
377
|
-
#}
|
|
378
|
-
##Wait for a rebuild
|
|
379
|
-
#expect(out).to readline_and_equal_x_within_y_seconds("BUILD RAN", 5.seconds)
|
|
380
|
-
|
|
381
|
-
##Grab new version
|
|
382
|
-
#application_user_js2 = wget "http://localhost:9992/application_user.js"
|
|
383
|
-
|
|
384
|
-
##Make sure the compiled file is different and it's longer
|
|
385
|
-
#expect(application_user_js2.length).to be > application_user_js.length
|
|
386
|
-
#expect(application_user_js2.length).to be > 30 #Make sure it's at least something
|
|
387
|
-
#end
|
|
388
|
-
#end
|
|
389
|
-
#end
|
|
218
|
+
it "Can build a project with an instantized service from the kernel ./app/kern/services folder" do
|
|
219
|
+
#Compiled to config/services.rb
|
|
220
|
+
def compile_with_file path=nil
|
|
221
|
+
config_src = File.read(path) if path
|
|
222
|
+
flok_new do
|
|
223
|
+
File.write "./config/services.rb", config_src if path
|
|
224
|
+
|
|
225
|
+
#Build a new project
|
|
226
|
+
flok "build"
|
|
227
|
+
|
|
228
|
+
#Check it's products directory
|
|
229
|
+
Dir.chdir "products" do
|
|
230
|
+
#Has a platform folder
|
|
231
|
+
Dir.chdir @platform do
|
|
232
|
+
application_user_js = File.read('application_user.js')
|
|
233
|
+
|
|
234
|
+
return application_user_js.split("\n").count
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
platform = ENV['PLATFORM']
|
|
241
|
+
@platform = platform
|
|
242
|
+
config_rb = File.read('./spec/etc/service_compiler/config0.rb')
|
|
243
|
+
|
|
244
|
+
#The file with content should be longer when compiled into the flat application_user.js
|
|
245
|
+
len_with_content = compile_with_file "./spec/etc/service_compiler/config0.rb"
|
|
246
|
+
len_no_content = compile_with_file
|
|
247
|
+
|
|
248
|
+
expect(len_no_content).to be < len_with_content
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
it "Can build a project with an instantized service from the user ./app/services folder" do
|
|
252
|
+
#Compiled to config/services.rb
|
|
253
|
+
def compile_with_file config_path=nil, src_path=nil
|
|
254
|
+
config_src = File.read(config_path) if config_path
|
|
255
|
+
src = File.read(src_path) if src_path
|
|
256
|
+
flok_new do
|
|
257
|
+
File.write "./config/services.rb", config_src if config_path
|
|
258
|
+
File.write "./app/services/service0.rb", src if src_path
|
|
259
|
+
|
|
260
|
+
#Build a new project
|
|
261
|
+
flok "build"
|
|
262
|
+
|
|
263
|
+
#Check it's products directory
|
|
264
|
+
Dir.chdir "products" do
|
|
265
|
+
#Has a platform folder
|
|
266
|
+
Dir.chdir @platform do
|
|
267
|
+
application_user_js = File.read('application_user.js')
|
|
268
|
+
|
|
269
|
+
return application_user_js.split("\n").count
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
platform = ENV['PLATFORM']
|
|
276
|
+
@platform = platform
|
|
277
|
+
config_rb = File.read('./spec/etc/service_compiler/config1.rb')
|
|
278
|
+
service_rb = File.read('./spec/etc/service_compiler/service0.rb')
|
|
279
|
+
|
|
280
|
+
#The file with content should be longer when compiled into the flat application_user.js
|
|
281
|
+
len_with_content = compile_with_file "./spec/etc/service_compiler/config1.rb", "./spec/etc/service_compiler/service0.rb"
|
|
282
|
+
len_no_content = compile_with_file
|
|
283
|
+
|
|
284
|
+
expect(len_no_content).to be < len_with_content
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
it "Can build a project with an instantized service from the user ./app/services folder and this has a function of the service" do
|
|
288
|
+
#Compiled to config/services.rb
|
|
289
|
+
def compile_with_file config_path=nil, src_path=nil
|
|
290
|
+
config_src = File.read(config_path) if config_path
|
|
291
|
+
src = File.read(src_path) if src_path
|
|
292
|
+
flok_new do
|
|
293
|
+
File.write "./config/services.rb", config_src if config_path
|
|
294
|
+
File.write "./app/services/service0.rb", src if src_path
|
|
295
|
+
|
|
296
|
+
#Build a new project
|
|
297
|
+
flok "build"
|
|
298
|
+
|
|
299
|
+
#Check it's products directory
|
|
300
|
+
Dir.chdir "products" do
|
|
301
|
+
#Has a platform folder
|
|
302
|
+
Dir.chdir @platform do
|
|
303
|
+
application_user_js = File.read('application_user.js')
|
|
304
|
+
|
|
305
|
+
return application_user_js
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
platform = ENV['PLATFORM']
|
|
312
|
+
@platform = platform
|
|
313
|
+
config_rb = File.read('./spec/etc/service_compiler/config1.rb')
|
|
314
|
+
service_rb = File.read('./spec/etc/service_compiler/service0.rb')
|
|
315
|
+
|
|
316
|
+
#The file with content should be longer when compiled into the flat application_user.js
|
|
317
|
+
res = compile_with_file "./spec/etc/service_compiler/config1.rb", "./spec/etc/service_compiler/service0.rb"
|
|
318
|
+
expect(res).to include("function blah_on_wakeup()")
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
include SpecHelpers #wget
|
|
322
|
+
it "server does host products on localhost:9992" do
|
|
323
|
+
platform = ENV['PLATFORM']
|
|
324
|
+
|
|
325
|
+
flok_new do
|
|
326
|
+
begin
|
|
327
|
+
rd, wr = IO.pipe
|
|
328
|
+
@pid = fork do
|
|
329
|
+
STDOUT.reopen(wr)
|
|
330
|
+
STDERR.reopen(wr)
|
|
331
|
+
exec("#{$flok_bin_path} server")
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
#Wait for server started
|
|
335
|
+
$stderr.puts "Waiting for server to start..."
|
|
336
|
+
$stderr.puts "="*100
|
|
337
|
+
loop do
|
|
338
|
+
res = rd.readline
|
|
339
|
+
$stderr.puts "[flok server]: #{res}"
|
|
340
|
+
break if res =~ /.*SERVER STARTED.*/
|
|
341
|
+
end
|
|
342
|
+
$stderr.puts "="*100
|
|
343
|
+
|
|
344
|
+
#Grab the application_user.js file
|
|
345
|
+
res = wget "http://localhost:9992/application_user.js"
|
|
346
|
+
expect(res).not_to eq(nil)
|
|
347
|
+
expect(res.length).not_to eq(0)
|
|
348
|
+
ensure
|
|
349
|
+
Process.kill :INT, @pid
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
it "server does host products on localhost:9992 and changes the products when the files change" do
|
|
355
|
+
platform = ENV['PLATFORM']
|
|
356
|
+
|
|
357
|
+
flok_new do
|
|
358
|
+
#Now execute the command with a set of arguments
|
|
359
|
+
|
|
360
|
+
begin
|
|
361
|
+
rd, wr = IO.pipe
|
|
362
|
+
@pid = fork do
|
|
363
|
+
STDOUT.reopen(wr)
|
|
364
|
+
STDERR.reopen(wr)
|
|
365
|
+
exec("#{$flok_bin_path} server")
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
#Wait for server started
|
|
369
|
+
$stderr.puts "Waiting for server to start..."
|
|
370
|
+
$stderr.puts "="*100
|
|
371
|
+
loop do
|
|
372
|
+
res = rd.readline
|
|
373
|
+
$stderr.puts "[flok server]: #{res}"
|
|
374
|
+
break if res =~ /.*SERVER STARTED.*/
|
|
375
|
+
end
|
|
376
|
+
$stderr.puts "="*100
|
|
377
|
+
|
|
378
|
+
#Grab the application_user.js file before making a change
|
|
379
|
+
res0 = wget "http://localhost:9992/application_user.js"
|
|
380
|
+
|
|
381
|
+
#Now add a file
|
|
382
|
+
File.write "./app/controllers/test2.rb", %{
|
|
383
|
+
controller "my_controller" do
|
|
384
|
+
action "my_action" do
|
|
385
|
+
on_entry %{
|
|
386
|
+
}
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
#Grab the application_user.js after adding a change
|
|
392
|
+
res1 = wget "http://localhost:9992/application_user.js"
|
|
393
|
+
|
|
394
|
+
#They shouldn't be nil or 0 length
|
|
395
|
+
expect(res0).not_to eq(nil); expect(res1).not_to eq(nil)
|
|
396
|
+
expect(res0.length).not_to eq(0); expect(res1.length).not_to eq(0)
|
|
397
|
+
|
|
398
|
+
#And they shouldn't be the same
|
|
399
|
+
expect(res0.length).to be < res1.length
|
|
400
|
+
ensure
|
|
401
|
+
Process.kill :INT, @pid
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
end
|
|
390
405
|
end
|