Update README.md and HACKING.md and resulting yak shave.

Update sky_server:
 - update its help string to admit that it wants the package path as well.
 - be quiet by default, since it makes the build chatty.
 - have a -v for verbose mode, for people who like it chatty.
 - have a default port of 8000, since that's what everyone used.
 - have a -p option to set the port, for people who don't use the default.
 - remove its mapping for gen/, since a TODO told me to.
 - remove the dependency on the build configuration, since it's no longer used.
 - teach it about .dart files.
 - rename sky_server/README to README.md, for consistency with other READMEs.
Update shelldb to speak the new sky_server protocol.
Update tests/services/iframe-embed-vmc.sky since the sky_server change broke the hack it was using.
Update skyserver.py to speak the new sky_server protocol.
Make webkitpy use SkyServer instead of spawning sky_server itself, since a TODO told me to.
Teach webkitpy about dart files.
Teach test_perf about dart files. (untested)
Teach sky_tool about main.dart, main.sky is deprecated. (untested)

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1200993002.
This commit is contained in:
Hixie
2015-06-22 13:39:16 -07:00
parent 6e9c30bfd8
commit a760718570
9 changed files with 91 additions and 92 deletions

View File

@@ -6,23 +6,34 @@ Building
* Follow the setup & build instructions for [Mojo](https://github.com/domokit/mojo)
The build directory will be `out/Debug` for Linux debug builds, and
`out/Release` for Linux release builds. For Android builds, prefix
`android_`, as in, `android_Debug`.
Running applications
--------------------
* ``./mojo/tools/mojodb start out/Debug [url]``
To run an application on your device, run:
`mojodb` has numerous commands, visible via `mojodb help`. Common ones include:
* `mojodb start` BUILD_DIR [url]
* `mojodb load` [url]
* `mojodb stop`
* `mojodb start_tracing` # Starts recoding a performance trace (use stop_tracing to stop)
* `mojodb print_crash` # Symbolicate the most recent crash from android.
* ``./mojo/tools/mojodb start out/android_Debug [url]``
`mojodb` has numerous commands, visible via `mojodb help`. Common ones include:
* `mojodb start` BUILD_DIR [url]
* `mojodb load` [url]
* `mojodb stop`
* `mojodb start_tracing` # Starts recoding a performance trace (use stop_tracing to stop)
* `mojodb print_crash` # Symbolicate the most recent crash from android.
Once `mojodb start` is issued, all subsequent commands will be sent to
the running mojo_shell instance (even on an attached android device).
`mojodb start` reads gn args from the passed build directory to
determine whether its using android, for example.
Running tests
-------------
Tests are only supported on Linux currently.
* ``./sky/tools/test_sky --debug``
* This runs the tests against ``//out/Debug``. If you want to run against
``//out/Release``, omit the ``--debug`` flag.
@@ -30,41 +41,22 @@ determine whether its using android, for example.
Running tests manually
----------------------
* ``sky/tools/skygo/linux64/sky_server -t Debug . 8000``
* ``out/Debug/mojo_shell --args-for="mojo:native_viewport_service --use-headless-config --use-osmesa" --args-for"=mojo:sky_viewer --testing" --content-handlers=text/sky,mojo:sky_viewer --url-mappings=mojo:window_manager=mojo:sky_tester,mojo:surfaces_service=mojo:fake_surfaces_service mojo:window_manager``
Running tests manually lets you more quickly iterate during
development; rather than having to compile and rerun all the tests,
then trawl through the build output to find the current results, you
can just run the test you're working on and reload it over and over,
seeing the output right there on your console.
* ``sky/tools/skygo/linux64/sky_server -v -p 8000 out/Debug out/Debug/gen/dart-pkg/packages``
* ``out/Debug/mojo_shell --args-for="mojo:native_viewport_service --use-headless-config --use-osmesa" --args-for"=mojo:sky_viewer --testing" --content-handlers=application/dart,mojo:sky_viewer --url-mappings=mojo:window_manager=mojo:sky_tester,mojo:surfaces_service=mojo:fake_surfaces_service mojo:window_manager``
* The ``sky_tester`` should print ``#READY`` when ready
* Type the URL you wish to run, for example ``http://127.0.0.1:8000/sky/tests/lowlevel/text.html``, and press the enter key
* Type the URL you wish to run, for example ``http://127.0.0.1:8000/sky/tests/widgets/dialog.dart``, and press the enter key
* The harness should print the results of the test. You can then type another URL.
Writing tests
-------------
* We recommend using the ``unittest.dart`` testing framework.
* See ``sky/tests/lowlevel/attribute-collection.sky`` for an example.
Adding pixel tests
------------------
Sky does not have proper pixel tests. Instead we have only reftests.
If you want a pixel test, you need to dump the png from a reftest,
upload it to googlestorage and then put and <img> pointing to the
uploaded file in the reference.
1. Create your test (e.g. foo.sky).
2. Create an dummy reference file (foo-expected.sky).
3. Run the test (it will fail).
4. Copy the -actual.png file to googlestorage (see below).
5. Put an ``<img>`` pointing to your newly uploaded png in the reference file at
http://storage.googleapis.com/mojo/sky-pngs/SHA1_HASH_HERE
Copying the file to googlestorage:
```bash
$ sha1sum ../out/Debug/layout-test-results/framework/flights-app-pixels-actual.png
db0508cdfe69e996a93464050dc383f6480f1283 ../out/Debug/layout-test-results/framework/flights-app-pixels-actual.png
$ gsutil.py cp ../out/Debug/layout-test-results/framework/flights-app-pixels-actual.png gs://mojo/sky-pngs/db0508cdfe69e996a93464050dc383f6480f1283
```
Long-term, we should not have these tests at all and should just
dump paint commands. In the short-term, if we find we're doing this
a lot we should obviously automate this process, e.g. test_sky could
do all of this work, including spitting out the correct reference file.
We recommend using the [Dart
``test``](https://pub.dartlang.org/packages/test) testing framework.
See [``sky/tests/raw/color_bounds.dart``](tests/raw/color_bounds.dart)
for an example.

View File

@@ -1,7 +1,14 @@
Sky
===
For information about using Sky, please see the
[Sky SDK](https://github.com/domokit/sky_sdk/).
For information about using our latest stable release of Sky, please
see the [Sky SDK](https://github.com/domokit/sky_sdk/) project page.
For information about contributing to Sky, please see [HACKING.md](HACKING.md).
For more current information about the bleeding edge of the Sky
framework, see [the sdk/ directory](sdk/lib/).
For details about the internals of Sky's engine, see [the engine/
directory](engine/).
For information about contributing to Sky, please see
[HACKING.md](HACKING.md).

View File

@@ -14,10 +14,7 @@ import 'package:mojo/core.dart';
import 'package:mojom/mojo/shell.mojom.dart' as shell_mojom;
import 'package:mojom/mojo/input_events.mojom.dart' as input_events;
import 'package:mojom/mojo/view_manager.mojom.dart' as view_manager;
// This include is a hack which only works with sky_server. For this to work
// in the sky_sdk, this echo_service would need to make its own dart package.
import '/gen/services/js/test/echo_service.mojom.dart' as echo_service_mojom;
import 'package:mojom/mojo/echo_service.mojom.dart' as echo_service_mojom;
class IFrameEmbed extends Application {
IFrameEmbed.fromHandle(MojoHandle handle) : super.fromHandle(handle);

View File

@@ -174,11 +174,8 @@ class StartSky(object):
return server_root
def _sky_server_for_args(self, args, packages_root):
# FIXME: This is a hack. sky_server should just take a build_dir
# not a magical "configuration" name.
configuration = os.path.basename(os.path.normpath(args.build_dir))
server_root = self._server_root_for_url(args.url_or_path)
sky_server = SkyServer(SKY_SERVER_PORT, configuration, server_root, packages_root)
sky_server = SkyServer(SKY_SERVER_PORT, server_root, packages_root)
return sky_server
def _find_remote_pid_for_package(self, package):

View File

@@ -1,5 +1,5 @@
sky_server instructions
#######################
=======================
Building locally:
1. cd sky/tools/skygo/linux64 (or your current platform)

View File

@@ -1 +1 @@
968d024a11557d4f77fea3ecdf6c3ef69bf214a1
925b384cf8e1fa916c51711fd462e85f5f4ad13d

View File

@@ -15,6 +15,8 @@ import (
"strings"
)
var verbose bool = false;
type skyHandlerRoot struct {
root string
}
@@ -29,63 +31,70 @@ func (handler *skyHandlerRoot) ServeHTTP(w http.ResponseWriter, r *http.Request)
return
}
path := path.Join(handler.root, r.URL.Path)
// Remove this one once .sky files are gone:
if strings.HasSuffix(path, ".sky") {
w.Header().Set("Content-Type", "text/sky")
}
if strings.HasSuffix(path, ".dart") {
w.Header().Set("Content-Type", "application/dart")
}
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path)
}
func usage() {
fmt.Fprintf(os.Stderr, "Usage: sky_server [flags] MOJO_SRC_ROOT PORT\n\n")
fmt.Fprintf(os.Stderr, "launches a basic http server with mappings into the\n")
fmt.Fprintf(os.Stderr, "mojo repository for framework/service paths.\n")
fmt.Fprintf(os.Stderr, "[flags] MUST be before arguments, because go:flag.\n\n")
fmt.Fprintf(os.Stderr, "Usage: sky_server [flags] MOJO_SRC_ROOT PACKAGE_ROOT\n")
fmt.Fprintf(os.Stderr, "Launches a basic http server with mappings into the mojo repository for framework/service paths.\n")
fmt.Fprintf(os.Stderr, "MOJO_SRC_ROOT must be the root of the Mojo repository.\n")
fmt.Fprintf(os.Stderr, "PACKAGE_ROOT must be the root of your Dart packages (e.g. out/Debug/gen/dart-pkg/packages/).\n")
flag.PrintDefaults()
os.Exit(2)
}
func addMapping(from_path string, to_path string) {
// Print to stderr to it's more obvious what this binary does.
fmt.Fprintf(os.Stderr, " %s -> %s\n", from_path, to_path)
if (verbose) {
fmt.Fprintf(os.Stderr, " %s -> %s\n", from_path, to_path)
}
http.Handle(from_path, http.StripPrefix(from_path, skyHandler(to_path)))
}
func main() {
var configuration = flag.String("t", "Release", "The target configuration (i.e. Release or Debug)")
flag.Parse()
flag.Usage = usage
// The built-in go:flag is awful. It only allows short-name arguments
// and they *must* be before any unnamed arguments. There are better ones:
// https://godoc.org/github.com/jessevdk/go-flags
// but for now we're using raw-go.
if flag.NArg() != 3 {
usage()
func setupMappings(mojoRoot string, packageRoot string, port int) {
if (verbose) {
fmt.Fprintf(os.Stderr, "Mappings for localhost:%v:\n", port)
fmt.Fprintf(os.Stderr, " / -> %s\n", mojoRoot)
}
http.Handle("/", skyHandler(mojoRoot))
root, _ := filepath.Abs(flag.Arg(0))
port := flag.Arg(1)
packageRoot := flag.Arg(2)
// genRoot should not be needed once we figure out how mojom generation
// for sdk users should work.
genRoot := path.Join(root, "out", *configuration, "gen")
fmt.Fprintf(os.Stderr, "Mappings for localhost:%s:\n", port)
fmt.Fprintf(os.Stderr, " / -> %s\n", root)
http.Handle("/", skyHandler(root))
fmt.Fprintf(os.Stderr, " /echo_post -> custom echo handler\n")
if (verbose) {
fmt.Fprintf(os.Stderr, " /echo_post -> custom echo handler\n")
}
http.HandleFunc("/echo_post", func(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
body, _ := ioutil.ReadAll(r.Body)
w.Write(body)
})
addMapping("/gen/", genRoot)
addMapping("/packages/", packageRoot)
http.ListenAndServe(":"+port, nil)
}
func main() {
var portPtr = flag.Int("p", 8000, "The HTTP port")
var verbosePtr = flag.Bool("v", false, "Verbose mode. Without this flag, the default behaviour only reports errors.")
flag.Parse()
flag.Usage = usage
if flag.NArg() != 2 {
usage()
}
var port int = *portPtr;
verbose = *verbosePtr;
root, _ := filepath.Abs(flag.Arg(0))
packageRoot := flag.Arg(1)
setupMappings(root, packageRoot, port);
http.ListenAndServe(fmt.Sprintf(":%v", port), nil)
}

View File

@@ -16,9 +16,8 @@ SKY_ROOT = os.path.dirname(SKY_TOOLS_PATH)
SRC_ROOT = os.path.dirname(SKY_ROOT)
class SkyServer(object):
def __init__(self, port, configuration, root, package_root):
def __init__(self, port, root, package_root):
self.port = port
self.configuration = configuration
self.root = root
self.package_root = package_root
self.server = None
@@ -54,9 +53,8 @@ class SkyServer(object):
os.chmod(self.sky_server_path(), st[stat.ST_MODE] | stat.S_IEXEC)
server_command = [
server_path,
'-t', self.configuration,
'-p', str(self.port),
self.root,
str(self.port),
self.package_root,
]
self.server = subprocess.Popen(server_command)

View File

@@ -15,9 +15,8 @@ import subprocess
SUPPORTED_MIME_TYPES = [
'text/html',
'text/sky',
'text/plain',
'application/dart',
]
HTTP_PORT = 9999
URL_ROOT = 'http://localhost:%s/' % HTTP_PORT