Skip to content

Include osx and windows testing on Travis #2299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,37 @@ sudo: false
dart:
- dev

os:
- linux
- osx
- windows

addons:
homebrew:
packages:
- coreutils

env:
global:
- SPLIT=`which gsplit || which split`

dart_task:
- test: --preset travis --total-shards 5 --shard-index 0
- test: --preset travis --total-shards 5 --shard-index 1
- test: --preset travis --total-shards 5 --shard-index 2
- test: --preset travis --total-shards 5 --shard-index 3
- test: --preset travis --total-shards 5 --shard-index 4
- test: --preset travis `$SPLIT -n l/1/7 .dart_tool/test_files`
- test: --preset travis `$SPLIT -n l/2/7 .dart_tool/test_files`
- test: --preset travis `$SPLIT -n l/3/7 .dart_tool/test_files`
- test: --preset travis `$SPLIT -n l/4/7 .dart_tool/test_files`
- test: --preset travis `$SPLIT -n l/5/7 .dart_tool/test_files`
- test: --preset travis `$SPLIT -n l/6/7 .dart_tool/test_files`
- test: --preset travis `$SPLIT -n l/7/7 .dart_tool/test_files`
- dartfmt
- dartanalyzer

# Create a snapshot to improve startup time. Tests will automatically use this
# snapshot if it's available.
before_script:
- dart --snapshot=bin/pub.dart.snapshot.dart2 bin/pub.dart
- find test -name "*_test\\.dart" | sort > .dart_tool/test_files
-

# Only building these branches means that we don't run two builds for each pull
# request.
Expand Down
25 changes: 21 additions & 4 deletions lib/src/git.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ class GitException implements ApplicationException {
/// The standard error emitted by git.
final String stderr;

/// The standard out emitted by git.
final String stdout;

/// The error code
final int exitCode;

@override
String get message => 'Git error. Command: git ${args.join(" ")}\n$stderr';
String get message => 'Git error. Command: `git ${args.join(' ')}`\n'
'stdout: $stdout\n'
'stderr: $stderr\n'
'exit code: $exitCode';

GitException(Iterable<String> args, this.stderr) : args = args.toList();
GitException(Iterable<String> args, this.stdout, this.stderr, this.exitCode)
: args = args.toList();

@override
String toString() => message;
Expand All @@ -48,7 +58,10 @@ Future<List<String>> run(List<String> args,
try {
var result = await runProcess(command, args,
workingDir: workingDir, environment: environment);
if (!result.success) throw GitException(args, result.stderr.join('\n'));
if (!result.success) {
throw GitException(args, result.stdout.join('\n'),
result.stderr.join('\n'), result.exitCode);
}
return result.stdout;
} finally {
log.unmuteProgress();
Expand All @@ -65,7 +78,11 @@ List<String> runSync(List<String> args,

var result = runProcessSync(command, args,
workingDir: workingDir, environment: environment);
if (!result.success) throw GitException(args, result.stderr.join('\n'));
if (!result.success) {
throw GitException(args, result.stdout.join('\n'), result.stderr.join('\n'),
result.exitCode);
}

return result.stdout;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/global_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class GlobalPackages {
var snapshotPath = p.join(binDir, '$basename.snapshot.dart2');
await dart.snapshot(url, snapshotPath,
packagesFile: p.toUri(_getPackagesFilePath(package.name)),
name: '${package.name}:${p.url.basenameWithoutExtension(path)}');
name: '${package.name}:${p.basenameWithoutExtension(path)}');
precompiled[p.withoutExtension(basename)] = snapshotPath;
}));
return precompiled;
Expand Down
10 changes: 9 additions & 1 deletion lib/src/source/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,21 @@ class PathSource extends Source {
dynamic serializeDescription(String containingPath, description) {
if (description['relative']) {
return {
'path': p.relative(description['path'], from: containingPath),
'path': relativePathWithPosixSeperators(
p.relative(description['path'], from: containingPath)),
'relative': true
};
}
return description;
}

/// On both Windows and linux we prefer `/` in the pubspec.lock for relative
/// paths.
static String relativePathWithPosixSeperators(String path) {
assert(p.isRelative(path));
return p.posix.joinAll(p.split(path));
}

/// Converts a parsed relative path to its original relative form.
@override
String formatDescription(description) {
Expand Down
2 changes: 1 addition & 1 deletion test/cache/repair/git_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void main() {
contains('Failed to load package:'),
contains('Could not find a file named "pubspec.yaml" in '),
contains('foo-'),
contains('/subdir'),
contains('${path.separator}subdir'),
]),
output: allOf([
startsWith('Failed to reinstall 2 packages:'),
Expand Down
7 changes: 6 additions & 1 deletion test/descriptor/git.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:async';

import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:pub/src/git.dart' as git;
import 'package:test_descriptor/test_descriptor.dart';
Expand All @@ -19,7 +20,11 @@ class GitRepoDescriptor extends DirectoryDescriptor {
await super.create(parent);
await _runGitCommands(parent, [
['init'],
['config', 'core.excludesfile', ''],
[
'config', 'core.excludesfile',
// TODO(sigurdm): This works around https://github.com/dart-lang/sdk/issues/40060
Platform.isWindows ? '""' : ''
],
['add', '.'],
['commit', '-m', 'initial commit', '--allow-empty']
]);
Expand Down
4 changes: 2 additions & 2 deletions test/descriptor/packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PackagesFileDescriptor extends Descriptor {
} else {
// Otherwise it's a path relative to the pubspec file,
// which is also relative to the .packages file.
packagePath = p.fromUri(version);
packagePath = version;
}
mapping[package] = p.toUri(p.join(packagePath, 'lib', ''));
});
Expand Down Expand Up @@ -78,7 +78,7 @@ class PackagesFileDescriptor extends Descriptor {
'Expected $description, found location: ${map[package]}.');
}
} else {
var expected = p.normalize(p.join(p.fromUri(description), 'lib'));
var expected = p.normalize(p.join(description, 'lib'));
var actual = p.normalize(p.fromUri(
p.url.relative(map[package].toString(), from: p.dirname(_base))));

Expand Down
5 changes: 3 additions & 2 deletions test/version_solver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:path/path.dart' as p;
import 'package:test/test.dart';
Expand Down Expand Up @@ -422,8 +423,8 @@ void devDependency() {
]).create();

await expectResolves(error: equalsIgnoringWhitespace('''
Because myapp depends on both foo from path foo and foo from path
../foo, version solving failed.
Because myapp depends on both foo from path foo and foo from path
..${Platform.pathSeparator}foo, version solving failed.
'''));
});
});
Expand Down