Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#1222 Updates to async test library. NOT YET WORKING.
- Loading branch information
1 parent
feafeb5
commit 122676a
Showing
20 changed files
with
1,787 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
SHELL = /bin/bash | ||
|
||
# list of executables required for the makefile to run. | ||
EXECUTABLES = defaults luarocks unlink busted | ||
K := $(foreach exec,$(EXECUTABLES),\ | ||
$(if $(shell which $(exec)),some string,$(error No `$(exec)` in PATH))) | ||
|
||
BundleID = org.latenitefilms.CommandPost | ||
APP_SUPPORT_PATH = ~/Library/Application\ Support | ||
CP_PATH = $(APP_SUPPORT_PATH)/CommandPost | ||
BID_PATH = $(APP_SUPPORT_PATH)/$(BundleID) | ||
EXT_PATH = $(CP_PATH)/Extensions | ||
PLUGIN_PATH = $(CP_PATH)/Plugins | ||
PREFS_PATH = ~/Library/Preferences | ||
PREFS_FILE = $(PREFS_PATH)/$(BundleID).plist | ||
|
||
CACHES_PATH = ~/Library/Caches | ||
CACHES = $(CACHES_PATH)/$(BundleID) $(CACHES_PATH)/io.fabric.sdk.mac.data/$(BundleID) $(CACHES_PATH)/com.crashlytics.data/$(BundleID) $(CACHES_PATH)/com.apple.nsurlsessiond/Downloads/$(BundleID) ~/Library/WebKit/$(BundleID) | ||
|
||
.PHONY: appscripts devscripts trashprefs trashsupport trashcaches | ||
|
||
test: | ||
@busted --help | ||
|
||
devscripts: $(PLUGIN_PATH) | ||
@defaults write $(BundleID) MJConfigFile "${PWD}/src/extensions/init.lua" | ||
@echo "CommandPost will load extensions and plugins from GitHub '${PWD}/src' folders." | ||
|
||
appscripts: | ||
@defaults delete $(BundleID) MJConfigFile | ||
@echo "CommandPost will load extensions and plugins from the bundled sources." | ||
|
||
trashprefs: | ||
@echo "Trashing CommandPost Preferences..." | ||
@defaults delete $(PREFS_FILE) | ||
@rm $(PREFS_FILE) | ||
|
||
trashsupport: | ||
@echo "Trashing CommandPost Application Support..." | ||
#@rm -R $(CP_PATH) | ||
#@rm -R $(BID_PATH) | ||
|
||
trashcaches: | ||
echo "Trashing Caches..." | ||
$(foreach cache,$(CACHES),\ | ||
$(shell rm -R $(cache)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- === cp.spec === | ||
--- | ||
--- An asynchronous test suite for Lua. | ||
local require = require | ||
|
||
local Handler = require "cp.spec.Handler" | ||
local DefaultHandler = require "cp.spec.DefaultHandler" | ||
local Result = require "cp.spec.Result" | ||
local Run = require "cp.spec.Run" | ||
local Definition = require "cp.spec.Definition" | ||
local Where = require "cp.spec.Where" | ||
local Scenario = require "cp.spec.Scenario" | ||
local Specification = require "cp.spec.Specification" | ||
|
||
--- cp.spec.describe(name) -> function(definitions) -> cp.spec.Specification | ||
--- Function | ||
--- Returns a `function` which will accept a list of test [Definitions](cp.spec.Definition.md), | ||
--- or a `table` of [Definitions](cp.spec.Definition.md). | ||
--- | ||
--- Parameters: | ||
--- * name - The name of the test suite. | ||
--- | ||
--- Returns: | ||
--- * A `function` that must be called with the set of [Definitions](cp.spec.Definition.md) or [suites](cp.spec.Specification.md) to run. | ||
local function describe(name) | ||
return function(...) | ||
return Specification(name):with(...) | ||
end | ||
end | ||
|
||
--- cp.spec.describe(name) -> function(definitions) -> cp.spec.Specification | ||
--- Function | ||
--- Returns a `function` which will accept a list of test [definitions](cp.spec.Definition.md), | ||
--- or a `table` of [definitions](cp.spec.Definition.md). | ||
--- | ||
--- Parameters: | ||
--- * name - The name of the test suite. | ||
--- | ||
--- Returns: | ||
--- * A `function` that must be called with the set of [definitions](cp.spec.Definition.md) or [suites](cp.spec.Specification.md) to run. | ||
local context = describe | ||
|
||
--- cp.spec.it(name[, ...]) -> cp.spec.Scenario | ||
--- Function | ||
--- Returns an [Scenario](cp.spec.Scenario.md) with the specified name and optional `doingFn` function. | ||
--- If the function is not provided, it must be done via the [doing](#doing) method prior to running. | ||
--- | ||
--- Parameters: | ||
--- * name - The name of the scenario. | ||
--- * doingFn - (optional) The `function` to call when doing the operation. Will be passed the [Run.This](cp.spec.Run.This.md) | ||
--- instance for the definition. | ||
--- | ||
--- Notes: | ||
--- * See [doing](cp.spec.Scenario.md#doing) for more details regarding the function. | ||
local function it(name, doingFn) | ||
return Scenario("it " .. name, doingFn) | ||
end | ||
|
||
--- cp.spec(item) -> cp.spec.Run | ||
local function run(item) | ||
local spec = require(item .. "_spec") | ||
return spec:run() | ||
end | ||
|
||
return setmetatable({ | ||
Handler = Handler, | ||
DefaultHandler = DefaultHandler, | ||
Result = Result, | ||
Run = Run, | ||
Definition = Definition, | ||
Scenario = Scenario, | ||
Where = Where, | ||
Specification = Specification, | ||
describe = describe, | ||
context = context, | ||
it = it, | ||
}, { | ||
__call = function(_, ...) | ||
return run(...) | ||
end | ||
}) |
Oops, something went wrong.