Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Fix Copy Targets To Root (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Nov 29, 2017
2 parents 2fb48d2 + ad92169 commit f36c278
Show file tree
Hide file tree
Showing 34 changed files with 570 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ branches:
platform:
- x64

version: 0.11.0-{build}
version: 0.12.1-{build}
skip_tags: true
clone_depth: 1

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ lib
output
npm-debug.log
lerna-debug.log
*-cache.yaml
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All significant changes to this project will be documented in the notes below.
This project adheres to [Semantic Versioning](http://semver.org/).

## [v0.12.1][] - 2017-11-29

### Fixed

- Cache validation no longer fails if output directory or other outputs have
be deleted since cache was written. This fixes an issue copying targets to
root after the output directory has been manually deleted by the user.

## [v0.12.0][] - 2017-11-25

### Added
Expand Down Expand Up @@ -237,6 +245,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Log parsing for Asymptote, BibTeX, Biber, and LaTeX.
- Configuration parsing in YAML or TeX magic comments.

[v0.12.1]: https://github.com/yitzchak/dicy/compare/v0.12.0...v0.12.1

[v0.12.0]: https://github.com/yitzchak/dicy/compare/v0.12.0-pre.0...v0.12.0

[v0.12.0-pre.0]: https://github.com/yitzchak/dicy/compare/v0.11.0...v0.12.0-pre.0
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dicy",
"version": "0.12.0",
"version": "0.12.1",
"description": "A builder for LaTeX, knitr, literate Agda, literate Haskell and Pweave that automatically builds dependencies.",
"keywords": [
"latex",
Expand Down Expand Up @@ -66,6 +66,7 @@
"@types/fs-extra": "^4.0.3",
"@types/graphlib": "^2.1.4",
"@types/jasmine": "^2.6.2",
"@types/jasmine-expect": "^3.6.1",
"@types/js-yaml": "^3.9.1",
"@types/lodash": "^4.14.80",
"@types/node": "^8.0.47",
Expand All @@ -76,6 +77,7 @@
"chalk-cli": "^4.0.0",
"fs-extra": "^4.0.2",
"jasmine": "^2.8.0",
"jasmine-expect": "^3.8.1",
"jasmine-ts": "^0.2.1",
"lerna": "^2.4.0",
"remark-cli": "^4.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
"@types/fs-extra": "^4.0.3",
"@types/graphlib": "^2.1.4",
"@types/jasmine": "^2.6.2",
"@types/jasmine-expect": "^3.6.1",
"@types/js-yaml": "^3.9.1",
"@types/lodash": "^4.14.80",
"@types/node": "^8.0.47",
"@types/semver": "^5.4.0",
"@types/temp": "^0.8.31",
"jasmine": "^2.8.0",
"jasmine-expect": "^3.8.1",
"jasmine-ts": "^0.2.1",
"rimraf": "^2.6.2",
"typescript": "^2.5.3"
Expand Down
27 changes: 23 additions & 4 deletions packages/core/spec/Builder_spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference path="../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../node_modules/@types/jasmine-expect/index.d.ts" />

import * as fs from 'fs-extra'
import * as path from 'path'
import * as readdir from 'readdir-enhanced'

Expand All @@ -13,8 +15,6 @@ const ASYNC_TIMEOUT = 50000
describe('Builder', () => {
let dicy: Builder
let fixturesPath: string
const testPath: string = path.join(__dirname, 'fixtures', 'builder-tests')
let tests: Array<string> = readdir.sync(testPath, { filter: /\.(lhs|tex|Rnw|lagda|Pnw)$/i })

beforeEach(async (done) => {
fixturesPath = await cloneFixtures()
Expand All @@ -23,6 +23,9 @@ describe('Builder', () => {
})

describe('can successfully build', () => {
const testPath: string = path.join(__dirname, 'fixtures', 'builder-tests')
let tests: Array<string> = readdir.sync(testPath, { filter: /\.(lhs|tex|Rnw|lagda|Pnw)$/i })

for (const name of tests) {
const spec: any = it(name, async (done) => {
let expected: Message[] = []
Expand All @@ -40,7 +43,7 @@ describe('Builder', () => {
}

// Run the builder
expect(await dicy.run(['load'])).toBeTruthy()
expect(await dicy.run(['load'])).toBeTrue()

if (!await dicy.run(['test'])) {
const errorMessages: string = messages.filter(message => message.severity === 'error').map(formatMessage).join('\n')
Expand All @@ -49,12 +52,28 @@ describe('Builder', () => {
return
}

expect(await dicy.run(['build', 'log', 'save'])).toBeTruthy()
expect(await dicy.run(['build', 'log', 'save'])).toBeTrue()

expect(messages).toReceiveMessages(expected)

done()
}, ASYNC_TIMEOUT)
}
})

describe('Caching functionality', () => {
it('Correctly loads and validates cache if outputs have been removed with copy targets enabled.', async (done) => {
const filePath: string = path.join(fixturesPath, 'cache-tests', 'copy-targets.tex')
const outputPath: string = path.join(fixturesPath, 'cache-tests', 'copy-targets.pdf')
let messages: Message[] = []
dicy = await Builder.create(filePath)
dicy.on('log', (newMessages: Message[]) => { messages = messages.concat(newMessages) })

expect(await dicy.run(['load', 'build'])).toBeTrue()
expect(messages).toReceiveMessages([])
expect(await fs.pathExists(outputPath)).toBeTrue()

done()
})
})
})
5 changes: 3 additions & 2 deletions packages/core/spec/Rules/Agda_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../../node_modules/@types/jasmine-expect/index.d.ts" />

import Agda from '../../src/Rules/Agda'
import { initializeRule, RuleDefinition } from '../helpers'
Expand All @@ -17,7 +18,7 @@ describe('Agda', () => {
it('returns true if literateAgdaEngine is \'agda\'', async (done) => {
const { rule } = await initialize()

expect(await Agda.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(true)
expect(await Agda.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeTrue()

done()
})
Expand All @@ -27,7 +28,7 @@ describe('Agda', () => {
options: { literateAgdaEngine: 'lhs2TeX' }
})

expect(await Agda.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(false)
expect(await Agda.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeFalse()

done()
})
Expand Down
7 changes: 4 additions & 3 deletions packages/core/spec/Rules/AssignJobNames_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../../node_modules/@types/jasmine-expect/index.d.ts" />

import AssignJobNames from '../../src/Rules/AssignJobNames'
import { initializeRule, RuleDefinition } from '../helpers'
Expand All @@ -14,9 +15,9 @@ describe('AssignJobNames', () => {
const source = await rule.getFile(rule.options.filePath)

if (source) {
expect(await rule.run()).toBe(true)
expect(await rule.run()).toBeTrue()

expect(Array.from(source.jobNames.values())).toEqual([])
expect(Array.from(source.jobNames.values())).toBeEmptyArray()
} else {
fail('Unable to retrieve test file.')
}
Expand All @@ -29,7 +30,7 @@ describe('AssignJobNames', () => {
const source = await rule.getFile(rule.options.filePath)

if (source) {
expect(await rule.run()).toBe(true)
expect(await rule.run()).toBeTrue()

expect(Array.from(source.jobNames.values())).toEqual(['foo'])
} else {
Expand Down
5 changes: 3 additions & 2 deletions packages/core/spec/Rules/BibTeX_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../../node_modules/@types/jasmine-expect/index.d.ts" />

import BibTeX from '../../src/Rules/BibTeX'
import { initializeRule, RuleDefinition } from '../helpers'
Expand Down Expand Up @@ -39,7 +40,7 @@ describe('BibTeX', () => {

if (file) {
const actions = await rule.getFileActions(file)
expect(actions).toEqual([])
expect(actions).toBeEmptyArray()
}

done()
Expand Down Expand Up @@ -87,7 +88,7 @@ describe('BibTeX', () => {
}]
}
const actions = await rule.getFileActions(file)
expect(actions).toEqual([])
expect(actions).toBeEmptyArray()
}

done()
Expand Down
3 changes: 2 additions & 1 deletion packages/core/spec/Rules/BibToGls_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../../node_modules/@types/jasmine-expect/index.d.ts" />

import BibToGls from '../../src/Rules/BibToGls'
import { initializeRule, RuleDefinition } from '../helpers'
Expand Down Expand Up @@ -39,7 +40,7 @@ describe('BibToGls', () => {

if (file) {
const actions = await rule.getFileActions(file)
expect(actions).toEqual([])
expect(actions).toBeEmptyArray()
}

done()
Expand Down
2 changes: 1 addition & 1 deletion packages/core/spec/Rules/Biber_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Biber', () => {
}]
}
const actions = await rule.getFileActions(file)
expect(actions).toEqual([])
expect(actions).toBeEmptyArray()
}

done()
Expand Down
13 changes: 7 additions & 6 deletions packages/core/spec/Rules/CheckForMissingBuildRule_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../../node_modules/@types/jasmine-expect/index.d.ts" />

import CheckForMissingBuildRule from '../../src/Rules/CheckForMissingBuildRule'
import Rule from '../../src/Rule'
Expand All @@ -22,7 +23,7 @@ describe('CheckForMissingBuildRule', () => {
}]
})

expect(await CheckForMissingBuildRule.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(true)
expect(await CheckForMissingBuildRule.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeTrue()

done()
})
Expand All @@ -34,7 +35,7 @@ describe('CheckForMissingBuildRule', () => {
}]
})

expect(await CheckForMissingBuildRule.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(false)
expect(await CheckForMissingBuildRule.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeFalse()

done()
})
Expand All @@ -49,7 +50,7 @@ describe('CheckForMissingBuildRule', () => {

await dicy.addRule(otherRule)

expect(await rule.run()).toBe(true)
expect(await rule.run()).toBeTrue()
expect(rule.log).not.toHaveBeenCalled()
} else {
fail('Unable to retrieve test file.')
Expand All @@ -61,7 +62,7 @@ describe('CheckForMissingBuildRule', () => {
it('run fails and logs an error messages when build rules are not present.', async (done) => {
const { rule } = await initialize()

expect(await rule.run()).toBe(false)
expect(await rule.run()).toBeFalse()
expect(rule.log).toHaveBeenCalledWith({
severity: 'error',
name: 'CheckForMissingBuildRule(build;finalize;;LaTeX_article.tex)',
Expand All @@ -81,7 +82,7 @@ describe('CheckForMissingBuildRule', () => {

await dicy.addRule(otherRule)

expect(await rule.run()).toBe(true)
expect(await rule.run()).toBeTrue()
expect(rule.log).not.toHaveBeenCalled()
} else {
fail('Unable to retrieve test file.')
Expand All @@ -95,7 +96,7 @@ describe('CheckForMissingBuildRule', () => {
options: { jobName: 'foo' }
})

expect(await rule.run()).toBe(false)
expect(await rule.run()).toBeFalse()
expect(rule.log).toHaveBeenCalledWith({
severity: 'error',
name: 'CheckForMissingBuildRule(build;finalize;foo;LaTeX_article.tex)',
Expand Down
13 changes: 7 additions & 6 deletions packages/core/spec/Rules/CopyTargetsToRoot_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../../node_modules/@types/jasmine-expect/index.d.ts" />

import * as path from 'path'

Expand All @@ -24,7 +25,7 @@ describe('CopyTargetsToRoot', () => {
})

rule.addTarget(rule.firstParameter.filePath)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(true)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeTrue()

done()
})
Expand All @@ -37,7 +38,7 @@ describe('CopyTargetsToRoot', () => {
})

rule.addTarget(filePath)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(false)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeFalse()

done()
})
Expand All @@ -50,7 +51,7 @@ describe('CopyTargetsToRoot', () => {
})

rule.addTarget(filePath)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(false)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeFalse()

done()
})
Expand All @@ -60,7 +61,7 @@ describe('CopyTargetsToRoot', () => {
options: { copyTargetsToRoot: true }
})

expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(false)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeFalse()

done()
})
Expand All @@ -69,7 +70,7 @@ describe('CopyTargetsToRoot', () => {
const { rule } = await initialize()

rule.addTarget(rule.firstParameter.filePath)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBe(false)
expect(await CopyTargetsToRoot.isApplicable(rule, 'build', 'execute', rule.parameters)).toBeFalse()

done()
})
Expand Down Expand Up @@ -97,7 +98,7 @@ describe('CopyTargetsToRoot', () => {

spyOn(rule.firstParameter, 'copy')

expect(await rule.run()).toBe(true)
expect(await rule.run()).toBeTrue()
expect(rule.firstParameter.copy).toHaveBeenCalledWith(destination)

done()
Expand Down

0 comments on commit f36c278

Please sign in to comment.