Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #13 from benansell/upgrade_elm-test_4.2
Browse files Browse the repository at this point in the history
Upgrade elm test 4.2
  • Loading branch information
benansell committed Sep 9, 2017
2 parents 0ed1102 + e57f71e commit a2d849d
Show file tree
Hide file tree
Showing 59 changed files with 441 additions and 341 deletions.
4 changes: 2 additions & 2 deletions .idea/runConfigurations/Integration___All.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/runConfigurations/Integration___elm_test_simple.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Unit___Mocha.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: node_js

node_js:
- "6"

cache:
directories:
- sysconfcpus
Expand All @@ -9,7 +12,7 @@ os:

env:
matrix:
- ELM_VERSION=0.18.0 TARGET_NODE_VERSION=node
- ELM_VERSION=0.18.0

before_install:
- | # see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142
Expand All @@ -21,8 +24,6 @@ before_install:
make && make install;
cd ..;
fi
- nvm install $TARGET_NODE_VERSION
- nvm use $TARGET_NODE_VERSION
- node --version
- npm --version
- npm install -g elm@$ELM_VERSION
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ follows:
lobo --testDirectory="test/unit"
```

### --testFile
Specify the relative path to the main elm tests file within the tests
directory. The default value is "Tests.elm"

### --verbose
Increases the verbosity of lobo logging messages. Please use this when
reporting an issue with lobo to get details about what lobo was trying
Expand Down
13 changes: 12 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
environment:
ELM_VERSION: "0.18.0"
matrix:
- nodejs_version: "4.6"
- nodejs_version: "4"

platform:
- x64

matrix:
fast_finish: true

init:
# report build worker details
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

install:
# update node version
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:Platform
- node --version
- npm --version

# install dependencies
- npm install -g elm@%ELM_VERSION%
- npm install

Expand All @@ -23,6 +30,10 @@ test_script:
- npm run test-ci

on_finish:
# pause before completion when $blockRdp is true
- ps: $blockRdp = $false;

# upload unit test results
- ps: |
$wc = New-Object 'System.Net.WebClient'
Get-ChildItem . -Name -Recurse '*-tests.xml' |
Expand Down
40 changes: 26 additions & 14 deletions lib/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface ElmPackageCompare {


export interface Builder {
build(config: LoboConfig, testDirectory: string): Bluebird<object>;
build(config: LoboConfig, testDirectory: string, testFile: string): Bluebird<object>;
}

export class BuilderImp implements Builder {
Expand All @@ -40,22 +40,23 @@ export class BuilderImp implements Builder {
this.util = util;
}

public build(config: LoboConfig, testDirectory: string): Bluebird<object> {
public build(config: LoboConfig, testDirectory: string, testFile: string): Bluebird<object> {
this.logger.info("-----------------------------------[ BUILD ]------------------------------------");

let baseElmPackageDir = ".";
let testElmPackageDir = testDirectory;
let testDir = path.dirname(testFile);
let steps: Array<() => Bluebird<object>> = [];

if (config.noUpdate) {
this.logger.info("Ignored sync of base and test elm-package.json files due to configuration");
} else {
steps = steps.concat([() => this.ensureElmPackageExists(config, baseElmPackageDir, "current"),
() => this.ensureElmPackageExists(config, testElmPackageDir, "tests"),
() => this.syncTestElmPackage(config, baseElmPackageDir, testElmPackageDir)]);
() => this.syncTestElmPackage(config, baseElmPackageDir, testElmPackageDir, testDir)]);
}

steps = steps.concat([() => this.installDependencies(config, testDirectory), () => this.make(config, testDirectory)]);
steps = steps.concat([() => this.installDependencies(config, testDirectory), () => this.make(config, testDirectory, testFile)]);

return Bluebird.mapSeries(steps, item => item());
}
Expand Down Expand Up @@ -88,9 +89,10 @@ export class BuilderImp implements Builder {
});
}

public syncTestElmPackage(config: LoboConfig, baseElmPackageDir: string, testElmPackageDir: string): Bluebird<object> {
public syncTestElmPackage(config: LoboConfig, baseElmPackageDir: string, testElmPackageDir: string, testDir: string): Bluebird<object> {
let steps = [() => this.readElmPackage(baseElmPackageDir, testElmPackageDir),
(result: ElmPackageCompare) => this.updateSourceDirectories(config, baseElmPackageDir, result.base, testElmPackageDir, result.test),
(result: ElmPackageCompare) =>
this.updateSourceDirectories(config, baseElmPackageDir, result.base, testElmPackageDir, testDir, result.test),
(result: ElmPackageCompare) => this.updateDependencies(config, result.base, testElmPackageDir, result.test)];

let value: ElmPackageCompare;
Expand Down Expand Up @@ -118,10 +120,10 @@ export class BuilderImp implements Builder {
}

public updateSourceDirectories(config: LoboConfig, baseElmPackageDir: string, baseElmPackage: ElmPackageJson, testElmPackageDir: string,
testElmPackage: ElmPackageJson): Bluebird<object> {
testDir: string, testElmPackage: ElmPackageJson): Bluebird<object> {
return new Bluebird((resolve: Resolve, reject: Reject) => {
let sourceDirectories =
this.mergeSourceDirectories(baseElmPackage, baseElmPackageDir, testElmPackage, testElmPackageDir, config.testFramework);
this.mergeSourceDirectories(baseElmPackage, baseElmPackageDir, testElmPackage, testElmPackageDir, testDir, config.testFramework);
let diff = _.difference(sourceDirectories, testElmPackage.sourceDirectories);

if (diff.length === 0) {
Expand Down Expand Up @@ -207,7 +209,7 @@ export class BuilderImp implements Builder {
}

public mergeSourceDirectories(baseElmPackage: ElmPackageJson, baseElmPackageDir: string, testElmPackage: ElmPackageJson,
testElmPackageDir: string, testFramework: PluginTestFrameworkWithConfig): string[] {
testElmPackageDir: string, testDir: string, testFramework: PluginTestFrameworkWithConfig): string[] {
let sourceDirs: string[] = _.clone(testElmPackage.sourceDirectories);

if (!sourceDirs) {
Expand All @@ -218,6 +220,10 @@ export class BuilderImp implements Builder {
sourceDirs.push(".");
}

if (sourceDirs.indexOf(testDir) === -1) {
sourceDirs.push(testDir);
}

sourceDirs = this.addSourceDirectories(baseElmPackage.sourceDirectories, baseElmPackageDir, testElmPackageDir, sourceDirs);

let dirPath = path.join(__dirname, "..");
Expand Down Expand Up @@ -297,6 +303,7 @@ export class BuilderImp implements Builder {
try {
// run as child process using current process stdio so that colored output is returned
let options = {cwd: directory, stdio: [process.stdin, process.stdout, process.stderr]};
this.logger.trace(command);
childProcess.execSync(command, options);
resolve();
} catch (err) {
Expand All @@ -306,7 +313,7 @@ export class BuilderImp implements Builder {
}
}

public make(config: LoboConfig, testDirectory: string): Bluebird<object> {
public make(config: LoboConfig, testDirectory: string, testFile: string): Bluebird<object> {
return new Bluebird((resolve: Resolve, reject: Reject) => {
let pluginDirectory = path.resolve(__dirname, "..", "plugin");
let testStuffMainElm = path.join(pluginDirectory, config.testFramework.config.name, config.testMainElm);
Expand All @@ -316,7 +323,11 @@ export class BuilderImp implements Builder {
command = path.join(config.compiler, command);
}

command += " " + testStuffMainElm + " --output=" + config.testFile;
if (testFile !== "Tests.elm") {
command += " " + testFile;
}

command += ` ${testStuffMainElm} --output=${config.testFile}`;

if (!config.prompt) {
command += " --yes";
Expand All @@ -329,12 +340,13 @@ export class BuilderImp implements Builder {
try {
// run as child process using current process stdio so that colored output is returned
let options = {cwd: testDirectory, stdio: [process.stdin, process.stdout, process.stderr]};
this.logger.trace(command);
childProcess.execSync(command, options);
resolve();
} catch (err) {
console.log("");
console.log(Chalk.red.bold(" BUILD FAILED"));
console.log("");
this.logger.error("");
this.logger.error(Chalk.bold(" BUILD FAILED"));
this.logger.error("");
this.logger.debug(err);
reject(err);
}
Expand Down
13 changes: 8 additions & 5 deletions lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class LoboImp implements Lobo {
let config = <LoboConfig> partialConfig;

let stages = [
() => this.builder.build(config, program.testDirectory),
() => this.builder.build(config, program.testDirectory, program.testFile),
() => this.runner.run(config)
];

Expand Down Expand Up @@ -217,6 +217,7 @@ export class LoboImp implements Lobo {
.option("--quiet", "only outputs build info, test summary and errors")
.option("--reporter <value>", "name of the reporter to use", "default-reporter")
.option("--testDirectory <value>", "directory containing the tests to run", "tests")
.option("--testFile <value>", "location of Tests.elm within the tests directory", "Tests.elm")
.option("--verbose", "outputs more detailed logging")
.option("--veryVerbose", "outputs very detailed logging")
.option("--watch", "watch for file changes and automatically rerun any effected tests");
Expand Down Expand Up @@ -307,16 +308,18 @@ export class LoboImp implements Lobo {
}
}

let testsElm = program.testDirectory + "/Tests.elm";
let testsElm = path.join(program.testDirectory, program.testFile);

if (!shelljs.test("-e", testsElm)) {
this.logger.error("");
this.logger.error("Unable to find \"Tests.elm\"");
this.logger.error(`Unable to find "${path.basename(program.testFile)}"`);
this.logger.error("Please check that it exists in the test directory:");
this.logger.error(path.resolve(program.testDirectory));
this.logger.error(path.resolve(path.dirname(testsElm)));
this.logger.info("");
this.logger.info("You can override the default location (\"./tests\") by running:");
this.logger.info("You can override the default location (\"./tests\") by running either:");
this.logger.info("lobo --testDirectory [directory containing Tests.elm]");
this.logger.info("or");
this.logger.info("lobo --testFile [relative path to main test file inside --testDirectory]");
exit = true;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/test-result-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export class TestResultFormatterImp implements TestResultFormatter {

if (lines[2].indexOf(TestResultFormatterImp.verticalBarMiddle + " ") !== -1) {
lines[0] = TestResultFormatterImp.verticalBarStart + " " + lines[0];
lines[1] = lines[1].replace("╷", TestResultFormatterImp.verticalBarMiddle);
lines[3] = lines[3].replace("╵", TestResultFormatterImp.verticalBarMiddle);
lines[1] = lines[1].replace(/(╵|╷)/, TestResultFormatterImp.verticalBarMiddle);
lines[3] = lines[3].replace(/(╵|╷)/, TestResultFormatterImp.verticalBarMiddle);
lines[4] = TestResultFormatterImp.verticalBarEnd + " " + lines[4];

let expectMessage = lines[2].substring(2, lines[2].length);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lobo",
"version": "0.3.2",
"version": "0.3.3",
"description": "Elm test runner",
"keywords": [
"elm",
Expand Down
6 changes: 5 additions & 1 deletion plugin/elm-test-extra/plugin-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export class ElmTestExtraConfig implements PluginTestFrameworkConfig {

public dependencies: Dependencies = {
"benansell/lobo-elm-test-extra": "2.0.0 <= v < 3.0.0",
"elm-community/elm-test": "4.0.0 <= v < 5.0.0",
"eeue56/elm-lazy": "1.0.0 <= v < 2.0.0",
"eeue56/elm-lazy-list": "1.0.0 <= v < 2.0.0",
"eeue56/elm-shrink": "1.0.0 <= v < 2.0.0",
"elm-community/elm-test": "4.2.0 <= v < 5.0.0",
"elm-lang/core": "5.0.0 <= v < 6.0.0",
"mgold/elm-random-pcg": "5.0.0 <= v < 6.0.0"
};

Expand Down
6 changes: 5 additions & 1 deletion plugin/elm-test/plugin-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export class ElmTestConfig implements PluginTestFrameworkConfig {
public sourceDirectories: string[] = ["runner", "plugin/elm-test"];

public dependencies: Dependencies = {
"elm-community/elm-test": "4.0.0 <= v < 5.0.0",
"eeue56/elm-lazy": "1.0.0 <= v < 2.0.0",
"eeue56/elm-lazy-list": "1.0.0 <= v < 2.0.0",
"eeue56/elm-shrink": "1.0.0 <= v < 2.0.0",
"elm-community/elm-test": "4.2.0 <= v < 5.0.0",
"elm-lang/core": "5.0.0 <= v < 6.0.0",
"mgold/elm-random-pcg": "5.0.0 <= v < 6.0.0"
};

Expand Down
1 change: 0 additions & 1 deletion test/integration/elm-lang/elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"elm-lang/geolocation": "1.0.2 <= v < 2.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/keyboard": "1.0.1 <= v < 2.0.0",
"elm-lang/lazy": "2.0.0 <= v < 3.0.0",
"elm-lang/mouse": "1.0.1 <= v < 2.0.0",
"elm-lang/navigation": "2.0.0 <= v < 3.0.0",
"elm-lang/page-visibility": "1.0.1 <= v < 2.0.0",
Expand Down
1 change: 0 additions & 1 deletion test/integration/elm-lang/src/ImportCheck.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import AnimationFrame
import Dom
import Geolocation
import Keyboard
import Lazy
import Mouse
import Navigation
import PageVisibility
Expand Down
Loading

0 comments on commit a2d849d

Please sign in to comment.