Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples to Travis #552

Merged
merged 7 commits into from
Feb 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,34 @@
# Unittest binaries
vibe-d
tests/*/tests

# Examples
examples/app_skeleton/__test__library__
examples/bench-http-request/bench-http-request
examples/bench-http-server/bench-http-server
examples/daytime/daytime-example
examples/diet/diet-example
examples/download/download-example
examples/echoserver/echoserver-example
examples/form_interface/form-interface-example
examples/http_info/http-info-example
examples/http_request/http-request-example
examples/http_reverse_proxy/http-reverse-proxy-example
examples/http_server/http-server-example
examples/http_static_server/http-static-server-example
examples/https_server/https-server-example
examples/json/json-example
examples/message/message-example
examples/mongodb/mongodb-example
examples/app_skeleton/app-skeleton
examples/redis-pubsub/redis-pubsub-example
examples/redis/redis-example
examples/rest/rest-example
examples/sendmail/sendmail-example
examples/serialization/serialization-example
examples/task_control/task-control-example
examples/tcp_separate/tcp-separate-example
examples/udp/udp-example
examples/uploader/uploader-example
examples/web/web-framework-example
examples/websocket/websocket-example
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ language: d
install:
# dmd
# dub
- DMD_VER=2.064.2
- DMD_VER=2.065.0
- DMD=dmd_${DMD_VER}-0_amd64.deb
- DUB_VER=0.9.21-rc.2
- DUB_VER=0.9.21
- DUB=dub-${DUB_VER}-linux-x86_64
- wget http://downloads.dlang.org/releases/2013/${DMD}
- wget http://downloads.dlang.org/releases/2014/${DMD}
- sudo dpkg -i ${DMD} || true
- sudo apt-get -y update
- sudo apt-get -fy install
Expand All @@ -20,3 +20,5 @@ install:

script:
- dub --config=unittest --build=unittest
- for ex in `\ls -1 examples/`; do (echo "[INFO] Building example $ex"; cd examples/$ex && dub build) || break; done
- for ex in `cat examples/.travis.run`; do (echo "[INFO] Running example $ex"; cd examples/$ex && dub test) || break; done
File renamed without changes.
23 changes: 23 additions & 0 deletions examples/.travis.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
app_skeleton
bench-http-request
bench-http-server
diet
download
echoserver
form_interface
http_info
http_request
http_reverse_proxy
http_server
https_server
http_static_server
json
message
rest
serialization
task_control
tcp_separate
udp
uploader
web
websocket
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Toni Tester"
],
"dependencies": {
"vibe-d": ">=0.7.12"
"vibe-d": {"version": "~master", "path": "../../"}
},
"versions": ["VibeDefaultMain"]
}
}
3 changes: 2 additions & 1 deletion examples/bench-http-request/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void request(bool disconnect)
void distTask()
{
static shared int s_threadCount = 0;
static shared int s_token = 0;
static shared long s_token = 0;
auto id = atomicOp!"+="(s_threadCount, 1) - 1;

while (true) {
Expand Down Expand Up @@ -86,6 +86,7 @@ void benchmark()
bool disconnect = ++keep_alives >= g_maxKeepAliveRequests;
request(disconnect);
if (disconnect) keep_alives = 0;
if (nreq >= 5000) exitEventLoop(true);
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/echoserver/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import vibe.core.net;

shared static this()
{
listenTCP(7, conn => conn.write(conn));
listenTCP(2000, conn => conn.write(conn));
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/http_info/views/info.dt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ html(lang="en")
head
title Info
body
h1 #{req.method} #{req.url}
h1 #{req.method} #{req.requestURL}

h2 Headers
dl
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions source/vibe/http/form.d
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private HTTPServerRequestDelegate formMethodHandler(T, string method)(T inst, Fl
void handler(HTTPServerRequest req, HTTPServerResponse res)
{
import std.traits;
string[string] form = req.method == HTTPMethod.GET ? req.query : req.form;
auto form = (req.method == HTTPMethod.GET ? req.query : req.form);
// alias MemberFunctionsTuple!(T, method) overloads;
string errors;
foreach(func; __traits(getOverloads, T, method)) {
Expand Down Expand Up @@ -291,8 +291,8 @@ private bool applyParametersFromAssociativeArray(Func)(HTTPServerRequest req, HT
private bool applyParametersFromAssociativeArray(alias Overload, Func)(HTTPServerRequest req, HTTPServerResponse res, Func func, out string error, Flag!"strict" strict) {
alias ParameterTypeTuple!Overload ParameterTypes;
ParameterTypes args;
string[string] form = req.method == HTTPMethod.GET ? req.query : req.form;
int count=0;
auto form = (req.method == HTTPMethod.GET ? req.query : req.form);
int count = 0;
Error e;
foreach(i, item; ParameterIdentifierTuple!Overload) {
static if(is(ParameterTypes[i] : HTTPServerRequest)) {
Expand All @@ -308,7 +308,9 @@ private bool applyParametersFromAssociativeArray(alias Overload, Func)(HTTPServe
error=e.message;
if(e.missing_parameters.length) {
error~="The following parameters have not been found in the form data: "~to!string(e.missing_parameters)~"\n";
error~="Provided form data was: "~to!string(form.keys)~"\n";
error~="Provided form data was: ";
foreach(k, v; form)
error ~= "[" ~ k ~ ":" ~ v ~ "] ";
}
if(count!=form.length) {
error~="The form had "~to!string(form.length)~" element(s), of which "~to!string(count)~" element(s) were applicable.\n";
Expand Down