Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve detect to be Revel specific

  • Loading branch information...
commit d786bb69a1eaa18796694f540081c85c904af981 1 parent 9b9d49b
@jamesward authored
View
2  bin/detect
@@ -2,7 +2,7 @@
# bin/detect <build-dir>
set -e
-if test -n "$(find "$1" -type f -name '*.go' | sed 1q)"
+if (test -e $1/conf/app.conf && test -e $1/conf/routes)
then echo Revel
else echo no; exit 1
fi
View
56 compile-test.sh
@@ -1,56 +0,0 @@
-#!/bin/sh
-
-# Default Go version is r59
-rdir=$PWD/cache/src/go/release.r59
-
-before() {
- mkdir -p build cache
- cp -r test/* build
-}
-
-after() {
- rm -rf tmp build
-}
-
-compile() {
- : === Compiling
- sh bin/compile build cache 2>&1
- : === Done compiling
-}
-
-# You can skip the long compile test by setting GOROOT
-[ -n "$GOROOT" ] &&
- mkdir -p $(dirname $rdir) &&
- rm -f $rdir &&
- # Fake a compile
- ln -s $GOROOT $rdir
-
-it_compiles_go() {
- # Skip this test if GOROOT is set
- [ -n "$GOROOT" ] && exit 0
-
- rm -rf cache
- mkdir cache
- ! test -f cache/src/go/release.r59/bin/gofmt
- compile
- test -f cache/src/go/release.r59/bin/gofmt
-}
-
-it_skips_go_compile_if_exists() {
- # We don't delete the cache dir in the tests so this
- # doesn't need to rebuild Go.
- test -f cache/src/go/release.r59/bin/gofmt
- compile | grep "Skipping build"
-}
-
-it_compiles_app() {
- compile
- test -f build/bin/mytest
- test -x build/bin/mytest
- test "$(./build/bin/mytest 2>&1)" = "ok"
-}
-
-it_deletes_cache() {
- # Here only to delete the cache dir
- rm -rf cache
-}
View
17 detect-test.sh 100644 → 100755
@@ -1,16 +1,7 @@
-before() {
- cp -r test detect-test
+it_is_revel_if_conf_files_exist() {
+ sh -x bin/detect test
}
-after() {
- rm -rf detect-test
-}
-
-it_is_go_if_go_files_under_src() {
- sh -x bin/detect detect-test/
-}
-
-it_is_not_go_without_all_sh_or_go_files() {
- rm -rf detect-test/src/*
- ! sh -x bin/detect detect-test/
+it_is_not_revel_if_conf_files_do_not_exist() {
+ ! sh -x bin/detect .
}
View
14 test/app/controllers/app.go
@@ -0,0 +1,14 @@
+package controllers
+
+import (
+ "github.com/robfig/revel"
+)
+
+type Application struct {
+ *rev.Controller
+}
+
+func (c Application) Index() rev.Result {
+ message := "hello, Revel"
+ return c.Render(message)
+}
View
43 test/app/tmp/main.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+ "flag"
+ "reflect"
+ "github.com/robfig/revel"
+
+ "github.com/jamesward/hellorevel/app/controllers"
+
+)
+
+var (
+ runMode *string = flag.String("runMode", "", "Run mode.")
+ port *int = flag.Int("port", 0, "By default, read from app.conf")
+ importPath *string = flag.String("importPath", "", "Go Import Path for the app.")
+ srcPath *string = flag.String("srcPath", "", "Path to the source root.")
+
+ // So compiler won't complain if the generated code doesn't reference reflect package...
+ _ = reflect.Invalid
+)
+
+func main() {
+ rev.INFO.Println("Running revel server")
+ flag.Parse()
+ rev.Init(*runMode, *importPath, *srcPath)
+
+ rev.RegisterController((*controllers.Application)(nil),
+ []*rev.MethodType{
+ &rev.MethodType{
+ Name: "Index",
+ Args: []*rev.MethodArg{
+ },
+ RenderArgNames: map[int][]string{
+ 13: []string{
+ "message",
+ },
+ },
+ },
+
+ })
+
+ rev.Run(*port)
+}
View
9 test/app/views/Application/Index.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>{{.message}}</title>
+</head>
+<body>
+ <h1>{{.message}}</h1>
+</body>
+</html>
View
22 test/conf/app.conf
@@ -0,0 +1,22 @@
+app.name=hellorevel
+app.secret=pJLzyoiDe17L36myt9812jkhsadf8128kjasdfjxz9cvc97812476u6yhjaksdvj
+http.addr=
+#http.port=9000
+
+[dev]
+results.pretty=true
+server.watcher=true
+
+log.trace.output = off
+log.info.output = stderr
+log.warn.output = stderr
+log.error.output = stderr
+
+[prod]
+results.pretty=false
+server.watcher=false
+
+log.trace.output = off
+log.info.output = off
+log.warn.output = %(app.name)s.log
+log.error.output = %(app.name)s.log
View
5 test/conf/routes
@@ -0,0 +1,5 @@
+# Routes
+# This file defines all application routes (Higher priority routes first)
+# ~~~~
+
+GET / Application.Index
View
5 test/src/mytest/main.go
@@ -1,5 +0,0 @@
-package main
-
-func main() {
- print("ok")
-}
Please sign in to comment.
Something went wrong with that request. Please try again.