Mercurial Hosting > luan
view scripts/test.luan @ 1200:1e351b0d385e
move remove_old_web_log_files to luanhost
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 01 Mar 2018 16:28:18 -0700 |
parents | 0f2890e2ba16 |
children | bcb39089e899 |
line wrap: on
line source
local Binary = require "luan:Binary.luan" local Html = require "luan:Html.luan" local Io = require "luan:Io.luan" local Luan = require "luan:Luan.luan" local Math = require "luan:Math.luan" local Package = require "luan:Package.luan" local String = require "luan:String.luan" local Table = require "luan:Table.luan" local Thread = require "luan:Thread.luan" local Time = require "luan:Time.luan" local Hosting = require "luan:host/Hosting.luan" local Http = require "luan:http/Http.luan" local Http_test = require "luan:http/Http_test.luan" local Server = require "luan:http/Server.luan" local Lucene = require "luan:lucene/Lucene.luan" local Versioning = require "luan:lucene/Versioning.luan" local Mail = require "luan:mail/Mail.luan" local error = Luan.error local range = Luan.range or error() local trim = String.trim or error() local find = String.find or error() local init = Http_test.init or error() local get_page = Http_test.get_page or error() local Ab_testing = require "luan:lucene/Ab_testing.luan" local function print(...) Io.print_to(Io.stderr,...) end function Io.schemes.site(path) return Io.uri( "luan:http/tools"..path ) end local page init() Http.request.parameters.code = "require('luan:Io.luan').print 'hi'" page = get_page "/run" trim(page) == "hi" or error "failed" init() Http.request.parameters.cmd = "'ab'..'cd'" page = get_page "/shell" find(page,"abcd") or error "failed" -- lucene local this_file = Io.schemes.file(Luan.arg[0]) local this_dir = this_file.parent() local lucene_dir = this_dir.parent().child("build").child("lucene_test") --print(lucene_dir.to_string()) local db = Lucene.index(lucene_dir.to_string()) db.delete_all() local ab_testing = Ab_testing.of(db) local test_events = {"all"} local aggregator_factories = { all = Ab_testing.count_all; } ab_testing.test{ name="All", values={"all"}, events=test_events, aggregator_factories=aggregator_factories } ab_testing.test{ name="null", values={"A","B"}, events=test_events, aggregator_factories=aggregator_factories } for record in range(1,10) do local doc = {type="test"} ab_testing.to_doc(doc) db.save(doc) end init() ab_testing.web_page{"All","null"}() local Web_search = require "luan:lucene/Web_search.luan" local web_search = Web_search.of(db) init() web_search() init() Http.request.parameters.query = "" Http.request.parameters.rows = "100" Http.request.parameters.sort = "" web_search() -- website function Io.schemes.site(path) return Io.uri( "file:../website/src"..path ) end init(); get_page "/" init(); get_page "/docs.html" init(); get_page "/tutorial.html" init(); get_page "/pil.html" init(); get_page "/manual.html" init(); get_page "/diff.html" init(); get_page "/examples/hi" init(); get_page "/examples/hi2" init(); get_page "/examples/shell" init() Http.request.parameters.name = "bob" page = get_page "/examples/hi2" find(page,"bob") or error "failed" print "done"