Skip to content

Commit

Permalink
Merge pull request #162 from franklinsch/truffle-lite
Browse files Browse the repository at this point in the history
Run behavior tests using lite
  • Loading branch information
franklinsch authored Apr 18, 2018
2 parents 89ac403 + 889c214 commit ccad247
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ zip:

test:
swift build -c release
cd Tests/BehaviorTests && ./compile_behavior_tests.sh
swift run -c release lite
cd Tests/BehaviorTests && ./run_behavior_tests.sh
28 changes: 25 additions & 3 deletions Sources/lite/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,35 @@ var fileCheckExecutableLocation: URL {
return findAdjacentBinary("file-check")!
}

func run() -> Int32 {
func runParserTests() -> Bool {
let allPassed = try! runLite(substitutions: [("flintc", "\(flintcExecutableLocation.path)"), ("FileCheck", "\"\(fileCheckExecutableLocation.path)\"")],
pathExtensions: ["flint"],
testDirPath: nil,
testDirPath: "Tests/ParserTests",
testLinePrefix: "//",
parallelismLevel: .automatic)
return allPassed ? EXIT_SUCCESS : EXIT_FAILURE
return allPassed
}

func runSemanticTests() -> Bool {
let allPassed = try! runLite(substitutions: [("flintc", "\(flintcExecutableLocation.path)")],
pathExtensions: ["flint"],
testDirPath: "Tests/SemanticTests",
testLinePrefix: "//",
parallelismLevel: .automatic)
return allPassed
}

func runBehaviorTests() -> Bool {
let allPassed = try! runLite(substitutions: [("flintc", "\(flintcExecutableLocation.path)")],
pathExtensions: ["js"],
testDirPath: "Tests/BehaviorTests",
testLinePrefix: "//",
parallelismLevel: .none)
return allPassed
}

func run() -> Int32 {
return runParserTests() && runSemanticTests() && runBehaviorTests() ? EXIT_SUCCESS : EXIT_FAILURE
}

exit(run())
1 change: 1 addition & 0 deletions Tests/BehaviorTests/compile_behavior_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ for t in tests/*; do

for f in $t/*.flint; do
[ -f "$f" ] || break
echo "Compile Flint file '$f'"
swift run -c release flintc $f --emit-ir --ir-output $t/test/contracts/
done

Expand Down
2 changes: 2 additions & 0 deletions Tests/BehaviorTests/tests/array/test/test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// RUN: cd %S && truffle test

var config = require("../config.js")

var Contract = artifacts.require("./" + config.contractName + ".sol");
Expand Down
2 changes: 2 additions & 0 deletions Tests/BehaviorTests/tests/bank/test/test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// RUN: cd %S && truffle test

var config = require("../config.js")

var Contract = artifacts.require("./" + config.contractName + ".sol");
Expand Down
2 changes: 2 additions & 0 deletions Tests/BehaviorTests/tests/dictionary/test/test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// RUN: cd %S && truffle test

var config = require("../config.js")

var Contract = artifacts.require("./" + config.contractName + ".sol");
Expand Down
2 changes: 2 additions & 0 deletions Tests/BehaviorTests/tests/factorial/test/test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// RUN: cd %S && truffle test

var config = require("../config.js")

var Contract = artifacts.require("./" + config.contractName + ".sol");
Expand Down
2 changes: 2 additions & 0 deletions Tests/BehaviorTests/tests/operators/test/test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// RUN: cd %S && truffle test

var config = require("../config.js")

var Contract = artifacts.require("./" + config.contractName + ".sol");
Expand Down
2 changes: 2 additions & 0 deletions Tests/BehaviorTests/tests/string/test/test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// RUN: cd %S && truffle test

var config = require("../config.js")

var Contract = artifacts.require("./" + config.contractName + ".sol");
Expand Down
2 changes: 2 additions & 0 deletions Tests/BehaviorTests/tests/structs/test/test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// RUN: cd %S && truffle test

var config = require("../config.js")

var Contract = artifacts.require("./" + config.contractName + ".sol");
Expand Down

0 comments on commit ccad247

Please sign in to comment.