#!/usr/bin/env bash # # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. # # A quick check over a subset the tests in the runtime, compiler # and client directories. # Currently builds and checks: # runtime - release mode # compiler - debug mode (non-optimized) # client - chromium debug mode global DO_OPTIMIZE := '0' global DO_DARTIUM := '0' global TESTS_FAILED := '0' proc usage { echo "usage: $0 [ --help ] [ --optimize ] [ --dartium ] " echo echo "Runs a quick set of tests on runtime, client, and compiler dirs" echo echo " --optimize: Also run dartc and client tests in release mode" echo " --dartium : Also run dartium/debug tests" echo } # Compile the vm/runtime # $1 directory to build in # $2 arch # $3 mode proc doBuild { ./tools/build.py --arch $1 --mode $2 if test $Status != 0 { echo "Build of $1 - $2 failed" exit 1 } } # Execute a set of tests # $1 directory to test in # $2 arch # $3 mode # Returns the output from the subcommand proc doTest { ./tools/test.py --component $2 --mode $3 global RESULT := $Status if test $(RESULT) != 0 { global TESTS_FAILED := '1' } return ${RESULT} } # Main while [ ! -z "$1" ] { matchstr $1 { "-h"|"-?"|"-help"|"--help" { usage exit 1 } "--optimize" { global DO_OPTIMIZE := '1' } "--dartium" { global DO_DARTIUM := '1' } * { echo "Unrecognized argument: $1" usage exit 1 } } shift } if test ! -d compiler -o ! -d runtime -o ! -d tests { echo "This doesn't look like the dart source tree." echo "Change your directory to the dart trunk source" exit 1 } echo echo "--- Building release ---" doBuild ia32 release echo echo "--- Building debug ---" doBuild ia32 debug echo echo "=== Runtime tests === " echo " Debug (Ctrl-C to skip this set of tests)" doTest runtime vm debug global RUNTIME_RESULT := $Status if test $(RUNTIME_RESULT) == 0 { echo " Release (Ctrl-C to skip this set of tests)" doTest runtime vm release global RUNTIME_RESULT := $Status } echo echo "=== dartc tests ===" echo " Debug mode (Ctrl-C to skip this set of tests)" doTest compiler dartc debug global DARTC_RESULT := $Status if test $(DO_OPTIMIZE) == 1 { echo " Release mode (--optimize)" doTest compiler dartc release global RESULT := $Status if test $(RESULT) != 0 { global DARTC_RESULT := $(RESULT) } } echo echo "=== Client tests ===" echo " Chromium (Ctrl-C to skip this set of tests)" doTest client chromium debug global CLIENT_RESULT := $Status if test $(DO_OPTIMIZE) == 1 { echo " Chromium Release mode (--optimize)" doTest compiler chromium release global RESULT := $Status if test $(RESULT) != 0 { global CLIENT_RESULT := $(RESULT) } } if test $(DO_DARTIUM) == 1 { echo " Dartium (Ctrl-C to skip this set of tests)" doTest client dartium release global RESULT := $Status if test $(RESULT) != 0 { global CLIENT_RESULT := $(RESULT) } } # Print summary of results if test $(RUNTIME_RESULT) != 0 { echo "*** vm tests failed" } if test $(DARTC_RESULT) != 0 { echo "*** dartc tests failed" } if test $(CLIENT_RESULT) != 0 { echo "*** client tests failed" } if test $(TESTS_FAILED) == 0 { echo "All presubmit tests passed!" } (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_OPTIMIZE) op:Equal rhs:{(0)} spids:[39])] spids: [39] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DO_DARTIUM) op:Equal rhs:{(0)} spids:[42])] spids: [42] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:TESTS_FAILED) op:Equal rhs:{(0)} spids:[45])] spids: [45] ) (FuncDef name: usage body: (BraceGroup children: [ (C {(echo)} {(DQ ("usage: ") ($ VSub_Number "$0") (" [ --help ] [ --optimize ] [ --dartium ] "))} ) (C {(echo)}) (C {(echo)} {(DQ ("Runs a quick set of tests on runtime, client, and compiler dirs"))}) (C {(echo)}) (C {(echo)} {(DQ (" --optimize: Also run dartc and client tests in release mode"))}) (C {(echo)} {(DQ (" --dartium : Also run dartium/debug tests"))}) (C {(echo)}) ] spids: [53] ) spids: [49 52] ) (FuncDef name: doBuild body: (BraceGroup children: [ (C {(./tools/build.py)} {(--arch)} {($ VSub_Number "$1")} {(--mode)} {($ VSub_Number "$2")}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} { (DQ ("Build of ") ($ VSub_Number "$1") (" - ") ($ VSub_Number "$2") (" failed")) } ) (C {(exit)} {(1)}) ] spids: [-1 142] ) ] spids: [-1 161] ) ] spids: [113] ) spids: [109 112] ) (FuncDef name: doTest body: (BraceGroup children: [ (C {(./tools/test.py)} {(--component)} {($ VSub_Number "$2")} {(--mode)} {($ VSub_Number "$3")} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [199] ) ] spids: [199] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name RESULT)} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TESTS_FAILED) op: Equal rhs: {(1)} spids: [223] ) ] spids: [223] ) ] spids: [-1 220] ) ] spids: [-1 227] ) (ControlFlow token: arg_word: {(${ VSub_Name RESULT)} ) ] spids: [185] ) spids: [181 184] ) (While cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "]")}) terminator: ) ] body: (DoGroup children: [ (Case to_match: {($ VSub_Number "$1")} arms: [ (case_arm pat_list: [{(DQ (-h))} {(DQ ("-?"))} {(DQ (-help))} {(DQ (--help))}] action: [(C {(usage)}) (C {(exit)} {(1)})] spids: [270 284 295 -1] ) (case_arm pat_list: [{(DQ (--optimize))}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DO_OPTIMIZE) op: Equal rhs: {(1)} spids: [304] ) ] spids: [304] ) ] spids: [299 301 308 -1] ) (case_arm pat_list: [{(DQ (--dartium))}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DO_DARTIUM) op: Equal rhs: {(1)} spids: [317] ) ] spids: [317] ) ] spids: [312 314 321 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(echo)} {(DQ ("Unrecognized argument: ") ($ VSub_Number "$1"))}) (C {(usage)}) (C {(exit)} {(1)}) ] spids: [325 326 345 -1] ) ] spids: [262 266 348] ) (C {(shift)}) ] spids: [259 353] ) ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-d)} {(compiler)} {(-o)} {(KW_Bang "!")} {(-d)} {(runtime)} {(-o)} {(KW_Bang "!")} {(-d)} {(tests)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("This doesn't look like the dart source tree."))}) (C {(echo)} {(DQ ("Change your directory to the dart trunk source"))}) (C {(exit)} {(1)}) ] spids: [-1 386] ) ] spids: [-1 407] ) (C {(echo)}) (C {(echo)} {(DQ ("--- Building release ---"))}) (C {(doBuild)} {(ia32)} {(release)}) (C {(echo)}) (C {(echo)} {(DQ ("--- Building debug ---"))}) (C {(doBuild)} {(ia32)} {(debug)}) (C {(echo)}) (C {(echo)} {(DQ ("=== Runtime tests === "))}) (C {(echo)} {(DQ (" Debug (Ctrl-C to skip this set of tests)"))}) (C {(doTest)} {(runtime)} {(vm)} {(debug)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RUNTIME_RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [462] ) ] spids: [462] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name RUNTIME_RESULT)} {(Lit_Other "=") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ (" Release (Ctrl-C to skip this set of tests)"))}) (C {(doTest)} {(runtime)} {(vm)} {(release)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RUNTIME_RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [502] ) ] spids: [502] ) ] spids: [-1 482] ) ] spids: [-1 505] ) (C {(echo)}) (C {(echo)} {(DQ ("=== dartc tests ==="))}) (C {(echo)} {(DQ (" Debug mode (Ctrl-C to skip this set of tests)"))}) (C {(doTest)} {(compiler)} {(dartc)} {(debug)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DARTC_RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [531] ) ] spids: [531] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name DO_OPTIMIZE)} {(Lit_Other "=") (Lit_Other "=")} {(1)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ (" Release mode (--optimize)"))}) (C {(doTest)} {(compiler)} {(dartc)} {(release)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [571] ) ] spids: [571] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name RESULT)} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DARTC_RESULT) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [595] ) ] spids: [595] ) ] spids: [-1 592] ) ] spids: [-1 601] ) ] spids: [-1 552] ) ] spids: [-1 603] ) (C {(echo)}) (C {(echo)} {(DQ ("=== Client tests ==="))}) (C {(echo)} {(DQ (" Chromium (Ctrl-C to skip this set of tests)"))}) (C {(doTest)} {(client)} {(chromium)} {(debug)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CLIENT_RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [628] ) ] spids: [628] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name DO_OPTIMIZE)} {(Lit_Other "=") (Lit_Other "=")} {(1)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ (" Chromium Release mode (--optimize)"))}) (C {(doTest)} {(compiler)} {(chromium)} {(release)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [668] ) ] spids: [668] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name RESULT)} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CLIENT_RESULT) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [692] ) ] spids: [692] ) ] spids: [-1 689] ) ] spids: [-1 698] ) ] spids: [-1 649] ) ] spids: [-1 700] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name DO_DARTIUM)} {(Lit_Other "=") (Lit_Other "=")} {(1)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ (" Dartium (Ctrl-C to skip this set of tests)"))}) (C {(doTest)} {(client)} {(dartium)} {(release)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: {($ VSub_QMark "$?")} spids: [739] ) ] spids: [739] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name RESULT)} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CLIENT_RESULT) op: Equal rhs: {(${ VSub_Name RESULT)} spids: [763] ) ] spids: [763] ) ] spids: [-1 760] ) ] spids: [-1 769] ) ] spids: [-1 720] ) ] spids: [-1 771] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name RUNTIME_RESULT)} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ("*** vm tests failed"))})] spids: [-1 794] ) ] spids: [-1 803] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name DARTC_RESULT)} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ("*** dartc tests failed"))})] spids: [-1 823] ) ] spids: [-1 832] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name CLIENT_RESULT)} {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ("*** client tests failed"))})] spids: [-1 852] ) ] spids: [-1 861] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name TESTS_FAILED)} {(Lit_Other "=") (Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ("All presubmit tests passed!"))})] spids: [-1 881] ) ] spids: [-1 890] ) ] )