This repository has been archived by the owner on Oct 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 921
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds system tests w/ travis and appveyor ci intergration
- Loading branch information
justin taft
committed
Oct 23, 2015
1 parent
25d98f7
commit dedeaae
Showing
11 changed files
with
362 additions
and
10 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
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,50 @@ | ||
environment: | ||
global: | ||
CYG_ROOT: C:\cygwin | ||
CYG_MIRROR: http://cygwin.mirror.constant.com | ||
CYG_CACHE: C:\cygwin\var\cache\setup | ||
CYG_BASH: C:\cygwin\bin\bash | ||
|
||
cache: | ||
- '%CYG_CACHE%' | ||
|
||
install: | ||
- 'echo Setting up Cygwin dependencies' | ||
- '%CYG_ROOT%\setup-x86.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P autoconf -P automake -P bison -P gcc-core -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ -P mingw-pthreads -P mingw-w32api -P libtool -P make -P python -P gettext-devel -P gettext -P intltool -P libiconv -P pkg-config -P git -P wget -P curl -P unzip -P psmisc> NUL' | ||
|
||
- 'echo Check Cygwin setup' | ||
- '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' | ||
- 'echo Done setting up Cygwin' | ||
|
||
- install lein | ||
- ps: | | ||
$base = "https://raw.githubusercontent.com/technomancy/leiningen/" | ||
$lein = $base + "stable/bin/lein.bat" | ||
(new-object net.webclient).DownloadFile($lein, "c:/projects/lighttable/lein.bat") | ||
- lein self-install | ||
- 'echo Done installing lein' | ||
#Add random location, this prevents qutation mark being added to | ||
#the current directory's path | ||
- cmd: 'set PATH="%PATH%;%cd%;c:\windows\system32"' | ||
- cmd: 'echo %PATH%' | ||
|
||
build_script: | ||
- cmd: 'echo Cygwin root is: %CYG_ROOT%' | ||
- cmd: 'echo Build folder is: %APPVEYOR_BUILD_FOLDER%' | ||
- cmd: 'echo Repo build branch is: %APPVEYOR_REPO_BRANCH%' | ||
- cmd: 'echo Repo build commit is: %APPVEYOR_REPO_COMMIT%' | ||
|
||
- cmd: 'echo creating lein reference' | ||
- '%CYG_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; echo \"#!/bin/bash\" > lein.sh"' | ||
- '%CYG_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; echo \"./lein.bat \$@\" >> lein.sh"' | ||
- '%CYG_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; chmod a+x lein.sh"' | ||
- '%CYG_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ln -s /cygdrive/c/projects/lighttable/lein.sh lein; ls -la"' | ||
|
||
- cmd: 'echo Running build.sh' | ||
- '%CYG_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ./script/build.sh"' | ||
- '%CYG_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ./script/run-tests.sh"' | ||
|
||
#DEBUG BEGIN, PAUSES BUILD PROCESS TO ALLOW FOR REMOTE DEBUGGING | ||
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) | ||
#- ps: throw "Failing tests" | ||
#DBEUG END |
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,4 @@ | ||
set LTPATH=%~dp0..\ | ||
|
||
c:\cygwin\bin\bash.exe -lc "cd `cygpath -u \"$LTPATH\"`; ./script/light-test.sh" | ||
|
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,2 @@ | ||
#!/bin/sh | ||
./script/light.sh &> /tmp/lt-debug |
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,53 @@ | ||
#!/bin/bash | ||
|
||
echo "Checking for chromedrive" | ||
ISWINDOWS=0 | ||
if [ "$(echo $(uname -s) | cut -c 1-9)" == "CYGWIN_NT" ]; then | ||
CHROMEDRIVER_PATH=/tmp/chromedriver.exe | ||
ISWINDOWS=1 | ||
else | ||
CHROMEDRIVER_PATH=/tmp/chromedriver | ||
fi | ||
|
||
|
||
if [ ! -f "$CHROMEDRIVER_PATH" ]; then | ||
|
||
# from: http://stackoverflow.com/a/17072017/142317 | ||
if [ "$(uname)" == "Darwin" ]; then | ||
URL="http://chromedriver.storage.googleapis.com/2.19/chromedriver_mac32.zip" | ||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then | ||
URL="http://chromedriver.storage.googleapis.com/2.19/chromedriver_linux64.zip" | ||
elif [ "$ISWINDOWS" == "1" ]; then | ||
URL="http://chromedriver.storage.googleapis.com/2.19/chromedriver_win32.zip" | ||
else | ||
echo "Cannot detect a supported OS." | ||
exit 1 | ||
fi | ||
|
||
echo "Downloading & extracting chromedriver." | ||
wget $URL -O /tmp/chromedriver.zip | ||
unzip /tmp/chromedriver.zip -d /tmp | ||
fi | ||
|
||
echo "Killing all chromedrivers & starting new instance". | ||
|
||
|
||
killall "chromedriver" | ||
killall "chromedriver.exe" | ||
|
||
chmod u+x $CHROMEDRIVER_PATH | ||
$CHROMEDRIVER_PATH& | ||
CHROME_PID=$! | ||
|
||
echo "Running tests" | ||
lein with-profile dev test | ||
RETURN_CODE=$? | ||
|
||
echo "===LIGHT TABLE DEBUG===" | ||
cat /tmp/lt-debug | ||
|
||
|
||
echo "Killing chrome" | ||
kill $CHROME_PID | ||
|
||
exit $RETURN_CODE |
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,34 @@ | ||
(ns lt.plugins.test-setup | ||
"Mocks & extends light table components for auotmated testing." | ||
(:require [clojure.string :as string] | ||
[lt.objs/popup :as popup] | ||
[lt.util.dom :as dom] | ||
[lt.objs.command :as cmd])) | ||
|
||
(def debug-file-path-input (atom "")) | ||
|
||
(defn show-file-dialog-mock | ||
"Mocks show-file-dialog so native file dialog does not show. | ||
A popup dialog with a text field is shown instead. File paths | ||
can be specified in the path fields, seperated by commas to donate | ||
multiple files." | ||
[type options callback] | ||
(popup/popup! {:body [:div [:h1 "File Dialog Mock"] [:input {:type "text" :id "debug-file-path"}]] | ||
:buttons | ||
[ | ||
{ | ||
:label "Okay" | ||
:action #(swap! debug-file-path-input (fn [_] (dom/val (dom/$ "#debug-file-path")))) | ||
:post-action #(callback (string/split @debug-file-path-input #",")) | ||
} | ||
] | ||
})) | ||
|
||
(cmd/command {:command :lt.testing.mock | ||
:desc "Test Env: Mocks light table components for automated tests." | ||
:exec #( | ||
;TODO error is thrown when evaling this, but it works... | ||
(lt.objs.dialogs/set-show-file-dialog-fn! show-file-dialog-mock) | ||
) | ||
}) | ||
|
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,117 @@ | ||
(ns lt.system-tests | ||
(:import | ||
(org.openqa.selenium Keys) | ||
(java.io File) | ||
(java.nio.file Path) | ||
(java.nio.file Paths) | ||
(java.nio.file Files) | ||
(java.nio.file.attribute FileAttribute) | ||
(java.nio.file OpenOption) | ||
(java.io File)) | ||
(:require | ||
[lt.webdriver-helper :as lt-webdriver-helper] | ||
[clj-webdriver.taxi :as taxi] | ||
[clj-webdriver.core :as core] | ||
[clj-webdriver.element :as element] | ||
[clojure.string :as str] | ||
[clojure.test :refer :all :as test])) | ||
|
||
|
||
(defn create-temporary-file [] | ||
(-> (Files/createTempFile (String. "temp-file-name") (String. ".tmp") (into-array FileAttribute [])) | ||
(.toAbsolutePath) | ||
(.toString))) | ||
|
||
|
||
(defn read-file-contents [path] | ||
(-> (Paths/get path (into-array String [])) | ||
(Files/readAllBytes) | ||
(String. ))) | ||
|
||
|
||
|
||
(defn helper-open-side-panel [] | ||
(taxi/send-keys (taxi/find-element {:css "body"}) | ||
(Keys/chord [ | ||
(core/key-code :control) | ||
(core/key-code :space)]))) | ||
|
||
(defn helper-select-side-panel-option [name] | ||
(-> (taxi/switch-to-active) | ||
(.sendKeys (into-array CharSequence (list name (core/key-code :enter)))))) | ||
|
||
;TODO implode files vector, comma seperated values | ||
(defn helper-select-files [files] | ||
(taxi/send-keys {:css "#debug-file-path"} (str (first files) "\n"))) | ||
|
||
(defn get-file-name-from-path [path] | ||
(-> (File. path) | ||
(.getName))) | ||
|
||
(defn lt-fixture [func] | ||
(lt-webdriver-helper/connect-to-light-table!) | ||
(func)) | ||
|
||
(use-fixtures :each lt-fixture) | ||
|
||
(deftest new-file | ||
|
||
;TODO write better method to test if | ||
;light table is finished initilaizing | ||
(Thread/sleep 20000) | ||
|
||
|
||
;Create temporary file | ||
(def temp-file-path (create-temporary-file)) | ||
|
||
;Enable test mocks for testing | ||
(helper-open-side-panel) | ||
(helper-select-side-panel-option "Test Env:") | ||
|
||
;Create new file | ||
(helper-open-side-panel) | ||
(helper-select-side-panel-option "new file") | ||
|
||
;Type some content | ||
(-> (element/init-element (taxi/switch-to-active)) | ||
(taxi/send-keys "File Persistence Test")) | ||
|
||
(Thread/sleep 1000) | ||
;Save file | ||
(helper-open-side-panel) | ||
(helper-select-side-panel-option "Save File") | ||
(helper-select-files [temp-file-path]) | ||
|
||
;Verify file contents | ||
(Thread/sleep 1000) | ||
(is (= "File Persistence Test" (read-file-contents temp-file-path))) | ||
|
||
;Close Tab | ||
(core/->actions (lt-webdriver-helper/get-webdriver) | ||
(core/move-to-element | ||
(taxi/find-element {:tag :span :class "file-name" :text (get-file-name-from-path temp-file-path) }))) | ||
|
||
(taxi/click {:css ".tabset.active .list li.active .tab-close"}) | ||
|
||
;Open file | ||
(helper-open-side-panel) | ||
(helper-select-side-panel-option "Open File") | ||
(helper-select-files [temp-file-path]) | ||
|
||
(Thread/sleep 500) | ||
|
||
;assert editor has correct text | ||
(is (= "File Persistence Test" | ||
(taxi/text {:css ".CodeMirror-code span"}))) | ||
|
||
(is (= "File Persistence Test I SHOULD FAIL" | ||
(taxi/text {:css ".CodeMirror-code span"}))) | ||
|
||
|
||
;Close Tab | ||
(Thread/sleep 1000) | ||
(core/->actions (lt-webdriver-helper/get-webdriver) | ||
(core/move-to-element | ||
(taxi/find-element {:tag :span :class "file-name" :text (get-file-name-from-path temp-file-path) }))) | ||
(taxi/click {:css ".tabset.active .list li.active .tab-close"}) | ||
) |
Oops, something went wrong.