Skip to content

Commit

Permalink
test: run all tests on Windows (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaugold authored Jul 5, 2022
1 parent 0c64d61 commit 44ba1e3
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 209 deletions.
80 changes: 36 additions & 44 deletions packages/melos/test/commands/exec_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:melos/melos.dart';
import 'package:melos/src/common/io.dart';
import 'package:melos/src/common/platform.dart';
import 'package:melos/src/common/utils.dart';
import 'package:path/path.dart';
import 'package:pubspec/pubspec.dart';
Expand All @@ -11,47 +10,45 @@ import '../utils.dart';

void main() {
group('exec', () {
test(
'supports package filter',
() async {
final workspaceDir = createTemporaryWorkspaceDirectory();
test('supports package filter', () async {
final workspaceDir = createTemporaryWorkspaceDirectory();

final aDir = await createProject(
workspaceDir,
const PubSpec(name: 'a'),
);
writeTextFile(join(aDir.path, 'log.txt'), '');
final aDir = await createProject(
workspaceDir,
const PubSpec(name: 'a'),
);
writeTextFile(join(aDir.path, 'log.txt'), '');

final bDir = await createProject(
workspaceDir,
const PubSpec(name: 'b'),
);
writeTextFile(join(bDir.path, 'log.txt'), '');
final bDir = await createProject(
workspaceDir,
const PubSpec(name: 'b'),
);
writeTextFile(join(bDir.path, 'log.txt'), '');

await createProject(
workspaceDir,
const PubSpec(name: 'c'),
);
await createProject(
workspaceDir,
const PubSpec(name: 'c'),
);

final logger = TestLogger();
final config = await MelosWorkspaceConfig.fromDirectory(workspaceDir);
final melos = Melos(
logger: logger,
config: config,
);
final logger = TestLogger();
final config = await MelosWorkspaceConfig.fromDirectory(workspaceDir);
final melos = Melos(
logger: logger,
config: config,
);

await melos.exec(
['echo', 'hello', 'world'],
concurrency: 1,
filter: PackageFilter(
fileExists: ['log.txt'],
),
);
await melos.exec(
['echo', 'hello', 'world'],
concurrency: 1,
filter: PackageFilter(
fileExists: ['log.txt'],
),
);

expect(
logger.output,
ignoringAnsii(
'''
expect(
logger.output.normalizeNewLines(),
ignoringAnsii(
'''
\$ melos exec
└> echo hello world
└> RUNNING (in 2 packages)
Expand All @@ -70,14 +67,9 @@ ${'-' * terminalWidth}
└> echo hello world
└> SUCCESS
''',
),
);
},
// TODO test is not compatible with Windows (windows prints
// `hello world\r\n` for carriage returns, whereas here they
// appear as `hello world\n`)
skip: currentPlatform.isWindows,
);
),
);
});

// TODO test that environemnt variables are injected
});
Expand Down
21 changes: 10 additions & 11 deletions packages/melos/test/commands/list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dart:convert';

import 'package:melos/src/commands/runner.dart';
import 'package:melos/src/common/glob.dart';
import 'package:melos/src/common/platform.dart';
import 'package:melos/src/package.dart';
import 'package:melos/src/workspace_configs.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import 'package:test/test.dart';

Expand Down Expand Up @@ -184,13 +184,16 @@ packages/c
test(
'full package path is printed by default if relativePaths is false or not set',
withMockFs(() async {
final packages = [
MockPackageFs(name: 'a'),
MockPackageFs(name: 'b'),
MockPackageFs(name: 'c'),
];
final workspaceDir = createMockWorkspaceFs(
packages: [
MockPackageFs(name: 'a'),
MockPackageFs(name: 'b'),
MockPackageFs(name: 'c'),
],
packages: packages,
);
final packagePaths = packages
.map((package) => p.join(workspaceDir.path, package.path));

final config = await MelosWorkspaceConfig.fromDirectory(workspaceDir);
final melos = Melos(logger: logger, config: config);
Expand All @@ -202,15 +205,11 @@ packages/c
logger.output,
ignoringAnsii(
'''
/melos_workspace/packages/a
/melos_workspace/packages/b
/melos_workspace/packages/c
${packagePaths.join('\n')}
''',
),
);
}),
// TODO test output is not compatible with windows
skip: currentPlatform.isWindows,
);
});

Expand Down
Loading

0 comments on commit 44ba1e3

Please sign in to comment.