Commit 3221ff79 authored by Caleb C. Sander's avatar Caleb C. Sander
Browse files

Concurrent tests no longer use phony targets

parent a4c2fd6f
Showing with 119 additions and 39 deletions
+119 -39
...@@ -4,6 +4,10 @@ tests/dag-scratch ...@@ -4,6 +4,10 @@ tests/dag-scratch
tests/dag-rebuild tests/dag-rebuild
tests/dag-touch tests/dag-touch
tests/dag-b-and-d tests/dag-b-and-d
tests/sleep1
tests/sleep2
tests/sleep1-sleep2
tests/sleep2-sleep1
tests/tree-scratch tests/tree-scratch
tests/tree-none tests/tree-none
tests/tree-remove-* tests/tree-remove-*
......
...@@ -2,41 +2,41 @@ module.exports = [ ...@@ -2,41 +2,41 @@ module.exports = [
{ {
target: 'sleep1', target: 'sleep1',
dependencies: ['sleep1-long', 'sleep1-short', 'sleep1-medium'], dependencies: ['sleep1-long', 'sleep1-short', 'sleep1-medium'],
command: ['node', 'sleep.js', '3.1'] command: ['node', '../sleep.js', '3', 'sleep1']
}, },
{ {
target: 'sleep1-short', target: 'sleep1-short',
dependencies: ['sleep.js'], dependencies: ['../sleep.js'],
command: ['node', 'sleep.js', '1'] command: ['node', '../sleep.js', '1', 'sleep1-short']
}, },
{ {
target: 'sleep1-medium', target: 'sleep1-medium',
dependencies: ['sleep.js'], dependencies: ['../sleep.js'],
command: ['node', 'sleep.js', '3'] command: ['node', '../sleep.js', '3', 'sleep1-medium']
}, },
{ {
target: 'sleep1-long', target: 'sleep1-long',
dependencies: ['sleep.js'], dependencies: ['../sleep.js'],
command: ['node', 'sleep.js', '5'] command: ['node', '../sleep.js', '5', 'sleep1-long']
}, },
{ {
target: 'sleep2', target: 'sleep2',
dependencies: ['sleep2-medium', 'sleep2-short', 'sleep2-long'], dependencies: ['sleep2-medium', 'sleep2-short', 'sleep2-long'],
command: ['node', 'sleep.js', '1.1'] command: ['node', '../sleep.js', '1', 'sleep2']
}, },
{ {
target: 'sleep2-short', target: 'sleep2-short',
dependencies: ['sleep.js'], dependencies: ['../sleep.js'],
command: ['node', 'sleep.js', '2'] command: ['node', '../sleep.js', '2', 'sleep2-short']
}, },
{ {
target: 'sleep2-medium', target: 'sleep2-medium',
dependencies: ['sleep.js'], dependencies: ['../sleep.js'],
command: ['node', 'sleep.js', '4'] command: ['node', '../sleep.js', '4', 'sleep2-medium']
}, },
{ {
target: 'sleep2-long', target: 'sleep2-long',
dependencies: ['sleep.js'], dependencies: ['../sleep.js'],
command: ['node', 'sleep.js', '6'] command: ['node', '../sleep.js', '6', 'sleep2-long']
} }
] ]
const fs = require('fs')
const seconds = Number(process.argv[2]) const seconds = Number(process.argv[2])
setTimeout(_ => console.log(`Slept for ${seconds} seconds`), seconds * 1e3) setTimeout(_ => console.log(`Slept for ${seconds} seconds`), seconds * 1e3)
fs.writeFile(process.argv[3], '', err => {
if (err) throw err
})
const fs = require('fs').promises
const path = require('path')
const test = require('ava') const test = require('ava')
const {execFilePromise, matchOutput} = require('./util') const {execFilePromise, matchOutput} = require('./util')
process.chdir(__dirname) process.chdir(__dirname)
async function make(...targets) { async function make(dir, ...targets) {
try { await fs.rmdir(dir, {recursive: true}) }
catch {}
await fs.mkdir(dir)
const {stdout} = await execFilePromise( const {stdout} = await execFilePromise(
'node', ['../make.js', 'concurrent-makefile.js', ...targets] 'node', ['../../make.js', '../concurrent-makefile.js', ...targets],
{cwd: path.join(__dirname, dir)}
) )
return stdout return stdout
} }
test('make sleep1', async t => { test('make sleep1', async t => {
// Test that the 3 sleeps happen at the same time // Test that the 3 sleeps happen at the same time
const output = await make('sleep1') const output = await make('sleep1', 'sleep1')
matchOutput(output, [ matchOutput(output, [
{target: 'start-sleep-short', dependencies: [], lines: ['node sleep.js 1']}, {
{target: 'start-sleep-medium', dependencies: [], lines: ['node sleep.js 3']}, target: 'start-sleep-short',
{target: 'start-sleep-long', dependencies: [], lines: ['node sleep.js 5']}, dependencies: [],
lines: ['node ../sleep.js 1 sleep1-short']
},
{
target: 'start-sleep-medium',
dependencies: [],
lines: ['node ../sleep.js 3 sleep1-medium']
},
{
target: 'start-sleep-long',
dependencies: [],
lines: ['node ../sleep.js 5 sleep1-long']
},
{ {
target: 'finish-sleep-short', target: 'finish-sleep-short',
dependencies: ['start-sleep-short', 'start-sleep-medium', 'start-sleep-long'], dependencies: ['start-sleep-short', 'start-sleep-medium', 'start-sleep-long'],
...@@ -32,22 +51,38 @@ test('make sleep1', async t => { ...@@ -32,22 +51,38 @@ test('make sleep1', async t => {
dependencies: ['finish-sleep-medium'], dependencies: ['finish-sleep-medium'],
lines: ['Slept for 5 seconds'] lines: ['Slept for 5 seconds']
}, },
{target: 'start-sleep1', dependencies: ['finish-sleep-long'], lines: ['node sleep.js 3.1']}, {
target: 'start-sleep1',
dependencies: ['finish-sleep-long'],
lines: ['node ../sleep.js 3 sleep1']
},
{ {
target: 'finish-sleep1', target: 'finish-sleep1',
dependencies: ['start-sleep1'], dependencies: ['start-sleep1'],
lines: ['Slept for 3.1 seconds'] lines: ['Slept for 3 seconds']
} }
]) ])
t.pass() t.pass()
}) })
test('make sleep2', async t => { test('make sleep2', async t => {
// Test that the 3 sleeps happen at the same time // Test that the 3 sleeps happen at the same time
const output = await make('sleep2') const output = await make('sleep2', 'sleep2')
matchOutput(output, [ matchOutput(output, [
{target: 'start-sleep-short', dependencies: [], lines: ['node sleep.js 2']}, {
{target: 'start-sleep-medium', dependencies: [], lines: ['node sleep.js 4']}, target: 'start-sleep-short',
{target: 'start-sleep-long', dependencies: [], lines: ['node sleep.js 6']}, dependencies: [],
lines: ['node ../sleep.js 2 sleep2-short']
},
{
target: 'start-sleep-medium',
dependencies: [],
lines: ['node ../sleep.js 4 sleep2-medium']
},
{
target: 'start-sleep-long',
dependencies: [],
lines: ['node ../sleep.js 6 sleep2-long']
},
{ {
target: 'finish-sleep-short', target: 'finish-sleep-short',
dependencies: ['start-sleep-short', 'start-sleep-medium', 'start-sleep-long'], dependencies: ['start-sleep-short', 'start-sleep-medium', 'start-sleep-long'],
...@@ -63,11 +98,15 @@ test('make sleep2', async t => { ...@@ -63,11 +98,15 @@ test('make sleep2', async t => {
dependencies: ['finish-sleep-medium'], dependencies: ['finish-sleep-medium'],
lines: ['Slept for 6 seconds'] lines: ['Slept for 6 seconds']
}, },
{target: 'start-sleep2', dependencies: ['finish-sleep-long'], lines: ['node sleep.js 1.1']}, {
target: 'start-sleep2',
dependencies: ['finish-sleep-long'],
lines: ['node ../sleep.js 1 sleep2']
},
{ {
target: 'finish-sleep2', target: 'finish-sleep2',
dependencies: ['start-sleep2'], dependencies: ['start-sleep2'],
lines: ['Slept for 1.1 seconds'] lines: ['Slept for 1 seconds']
} }
]) ])
t.pass() t.pass()
...@@ -75,14 +114,38 @@ test('make sleep2', async t => { ...@@ -75,14 +114,38 @@ test('make sleep2', async t => {
for (const targets of [['sleep1', 'sleep2'], ['sleep2', 'sleep1']]) { for (const targets of [['sleep1', 'sleep2'], ['sleep2', 'sleep1']]) {
test(`make ${targets.join(' ')}`, async t => { test(`make ${targets.join(' ')}`, async t => {
// Test that both targets are built at the same time // Test that both targets are built at the same time
const output = await make(...targets) const output = await make(targets.join('-'), ...targets)
matchOutput(output, [ matchOutput(output, [
{target: 'start-sleep1-short', dependencies: [], lines: ['node sleep.js 1']}, {
{target: 'start-sleep2-short', dependencies: [], lines: ['node sleep.js 2']}, target: 'start-sleep1-short',
{target: 'start-sleep1-medium', dependencies: [], lines: ['node sleep.js 3']}, dependencies: [],
{target: 'start-sleep2-medium', dependencies: [], lines: ['node sleep.js 4']}, lines: ['node ../sleep.js 1 sleep1-short']
{target: 'start-sleep1-long', dependencies: [], lines: ['node sleep.js 5']}, },
{target: 'start-sleep2-long', dependencies: [], lines: ['node sleep.js 6']}, {
target: 'start-sleep2-short',
dependencies: [],
lines: ['node ../sleep.js 2 sleep2-short']
},
{
target: 'start-sleep1-medium',
dependencies: [],
lines: ['node ../sleep.js 3 sleep1-medium']
},
{
target: 'start-sleep2-medium',
dependencies: [],
lines: ['node ../sleep.js 4 sleep2-medium']
},
{
target: 'start-sleep1-long',
dependencies: [],
lines: ['node ../sleep.js 5 sleep1-long']
},
{
target: 'start-sleep2-long',
dependencies: [],
lines: ['node ../sleep.js 6 sleep2-long']
},
{ {
target: 'finish-sleep1-short', target: 'finish-sleep1-short',
dependencies: [ dependencies: [
...@@ -115,22 +178,30 @@ for (const targets of [['sleep1', 'sleep2'], ['sleep2', 'sleep1']]) { ...@@ -115,22 +178,30 @@ for (const targets of [['sleep1', 'sleep2'], ['sleep2', 'sleep1']]) {
dependencies: ['finish-sleep2-medium'], dependencies: ['finish-sleep2-medium'],
lines: ['Slept for 5 seconds'] lines: ['Slept for 5 seconds']
}, },
{target: 'start-sleep1', dependencies: ['finish-sleep1-long'], lines: ['node sleep.js 3.1']}, {
target: 'start-sleep1',
dependencies: ['finish-sleep1-long'],
lines: ['node ../sleep.js 3 sleep1']
},
{ {
target: 'finish-sleep2-long', target: 'finish-sleep2-long',
dependencies: ['start-sleep1'], dependencies: ['start-sleep1'],
lines: ['Slept for 6 seconds'] lines: ['Slept for 6 seconds']
}, },
{target: 'start-sleep2', dependencies: ['finish-sleep2-long'], lines: ['node sleep.js 1.1']}, {
target: 'start-sleep2',
dependencies: ['finish-sleep2-long'],
lines: ['node ../sleep.js 1 sleep2']
},
{ {
target: 'finish-sleep2', target: 'finish-sleep2',
dependencies: ['start-sleep2'], dependencies: ['start-sleep2'],
lines: ['Slept for 1.1 seconds'] lines: ['Slept for 1 seconds']
}, },
{ {
target: 'finish-sleep1', target: 'finish-sleep1',
dependencies: ['finish-sleep2'], dependencies: ['finish-sleep2'],
lines: ['Slept for 3.1 seconds'] lines: ['Slept for 3 seconds']
} }
]) ])
t.pass() t.pass()
......
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