Commit 3050dc58 authored by David Owens II's avatar David Owens II

Fixed the model and added the first test

The model has public properties now…
The parser and tests now link with the model.
Basic test in place for parser validation.
parent 772b1c52
Pipeline #673 passed with stage
......@@ -14,7 +14,7 @@
;; The build file for all of the targets of the Anarchy Tools build tool.
(defpackage
(package
:name "atbuild"
:tasks {:hellworld {:tool "shell"
......@@ -67,12 +67,12 @@
:outputType "static-library"
:linkWithProduct ["atpkgmodel.a"]}
:atpkg-tests {:dependencies ["atpkg-parser"]
:atpkg-tests {:dependencies ["atpkg-parser", "atpkg-model"]
:tool "atllbuild"
:source ["parsers/atpkg/tests/**.swift"]
:name "atpkgtests"
:outputType "executable"
:linkWithProduct ["atpkparser.a"]}
:linkWithProduct ["atpkparser.a", "atpkgmodel.a"]}
:run-atpkg-tests {:dependencies ["atpkg-tests"]
:tool "shell"
......
......@@ -61,12 +61,12 @@ tasks:
linkWithProduct: ["atpkgmodel.a"]
atpkg-tests:
dependency: ["atpkg-parser"]
dependency: ["atpkg-parser", "atpkg-model"]
tool: "atllbuild"
source: ["parsers/atpkg/tests/**.swift"]
name: "atpkgtests"
outputType: "executable"
linkWithProduct: ["atpkgparser.a"]
linkWithProduct: ["atpkgparser.a", "atpkgmodel.a"]
run-atpkg-tests:
dependency: ["atpkg-tests"]
......
......@@ -19,9 +19,9 @@ public enum OutputType {
}
public class FilePath {
var path: String
public var path: String
var expandedItems: [String] {
public var expandedItems: [String] {
get { return [] }
}
......@@ -39,16 +39,20 @@ public class Dependency {
}
public class Task {
var dependencies: [Dependency] = []
var tool: String = "atllbuild"
var source: [FilePath] = []
var name: String
var bootstrapOnly: Bool = false
var llbuildyaml: String = ""
var linkSDK: Bool = false
var compilerOptions: [String] = []
var outputType: OutputType = OutputType.StaticLibrary
var linkWithProduct: [String] = []
// The required properties.
public var name: String
// The optional properties. All optional properties must have a default value.
public var dependencies: [Dependency] = []
public var tool: String = "atllbuild"
public var source: [FilePath] = []
public var version: String = ""
public var bootstrapOnly: Bool = false
public var llbuildyaml: String = ""
public var linkSDK: Bool = false
public var compilerOptions: [String] = []
public var outputType: OutputType = OutputType.StaticLibrary
public var linkWithProduct: [String] = []
public init(name: String) {
self.name = name
......@@ -56,8 +60,8 @@ public class Task {
}
public class Package {
var name: String
var tasks: [Task] = []
public var name: String
public var tasks: [Task] = []
public init(name: String) {
self.name = name
......
......@@ -14,6 +14,11 @@
import atpkgmodel
public class Parser {
public enum PackageParserError: ErrorType {
case PackageFileDoesNotExist
}
public func parsePackageDefinition(filepath: String) throws -> Package {
throw PackageParserError.PackageFileDoesNotExist
}
\ No newline at end of file
......@@ -64,7 +64,7 @@ class LexerTests: Test {
try test.assert(Token.isEqual(lexer.next(), to: Token.Comment(" This is the most basic of sample files.", line: 0, column: 0)))
try test.assert(Token.isEqual(lexer.next(), to: Token.Terminal(line: 1, column: 0)))
try test.assert(Token.isEqual(lexer.next(), to: Token.OpenParen(line: 2, column: 0)))
try test.assert(Token.isEqual(lexer.next(), to: Token.Identifier("project", line: 2, column: 1)))
try test.assert(Token.isEqual(lexer.next(), to: Token.Identifier("package", line: 2, column: 1)))
try test.assert(Token.isEqual(lexer.next(), to: Token.Terminal(line: 2, column: 8)))
try test.assert(Token.isEqual(lexer.next(), to: Token.Colon(line: 3, column: 2)))
try test.assert(Token.isEqual(lexer.next(), to: Token.Identifier("name", line: 3, column: 3)))
......
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import Foundation
import atpkgparser
import atpkgmodel
class ParserTests: Test {
required init() {}
let tests = [
ParserTests.testBasic
]
let filename = __FILE__
static func testBasic() throws {
let filepath = "./parsers/atpkg/tests/collateral/basic.atpkg"
let package = try parsePackageDefinition(filepath)
try test.assert(package.name == "basic")
}
}
\ No newline at end of file
......@@ -95,12 +95,12 @@ class ScannerTests: Test {
try test.assert(scanner.next()?.character == "\n")
try test.assert(scanner.next()?.character == "(")
try test.assert(scanner.next()?.character == "p")
try test.assert(scanner.next()?.character == "r")
try test.assert(scanner.next()?.character == "o")
try test.assert(scanner.next()?.character == "j")
try test.assert(scanner.next()?.character == "e")
try test.assert(scanner.next()?.character == "a")
try test.assert(scanner.next()?.character == "c")
try test.assert(scanner.next()?.character == "t")
try test.assert(scanner.next()?.character == "k")
try test.assert(scanner.next()?.character == "a")
try test.assert(scanner.next()?.character == "g")
try test.assert(scanner.next()?.character == "e")
try test.assert(scanner.next()?.character == "\n")
try test.assert(scanner.next()?.character == " ")
try test.assert(scanner.next()?.character == " ")
......
;; This is the most basic of sample files.
(project
(package
:name "basic"
:version "0.1.0-dev"
......
......@@ -37,7 +37,12 @@ extension Test {
func runTests() {
print("Tests for \(filename)")
for test in tests {
let _ = try? test()
do {
try test()
}
catch {
print("\(filename): **FAILED** \(error)")
}
}
}
}
......@@ -48,7 +53,8 @@ let tests: [Test] = [
// NOTE: Add your test classes here...
ScannerTests(),
LexerTests()
LexerTests(),
ParserTests()
]
for test in tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment