Skip to content
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

Fixed tests on windows #207

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/src/tzdata/zone_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class LocationDescriptionDatabase {
LocationDescriptionDatabase(this.locations);

factory LocationDescriptionDatabase.fromString(String data) {
final lines = data.split('\n');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary given the fix in tool/encode_tzf.dart?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this change modified the line ends from windows convention (CR+LF='\r\n') to Unix (LF only='\n'), before the split on LF only. Without this line there are CR remaining in the strings.

The change in encode_tzf.dart changes backward slashes '' with forward slashes '/' in the names of the timezones. (The backward slashes are coming form the filepaths on windows.)

final lines = data.replaceAll('\r\n', '\n').split('\n');
final locations = <LocationDescription>[];
for (final line in lines) {
if (line.isEmpty || line[0].startsWith('#')) {
Expand Down
2 changes: 1 addition & 1 deletion test/zicfile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() {
test('Read US/Eastern 2014h tzfile', () async {
var packageUri = Uri(scheme: 'package', path: 'timezone/timezone.dart');
var packagePath = p.dirname(
p.dirname((await Isolate.resolvePackageUri(packageUri))!.path));
p.dirname((await Isolate.resolvePackageUri(packageUri))!.toFilePath()));
var locationDir = p.join(packagePath, 'test');
var rawData =
await File(p.join(locationDir, 'data/US/Eastern')).readAsBytes();
Expand Down
2 changes: 1 addition & 1 deletion test/zone_tab_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() {
test('Read zone1970.tab file', () async {
var packageUri = Uri(scheme: 'package', path: 'timezone/timezone.dart');
var packagePath = p.dirname(
p.dirname((await Isolate.resolvePackageUri(packageUri))!.path));
p.dirname((await Isolate.resolvePackageUri(packageUri))!.toFilePath()));
var locationDir = p.join(packagePath, 'test');
var rawData =
await File(p.join(locationDir, 'data/zone1970.tab')).readAsString();
Expand Down
2 changes: 1 addition & 1 deletion tool/encode_tzf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<void> main(List<String> arguments) async {
final files = await Glob('**').list(root: zoneinfoPath).toList();
for (final f in files) {
if (f is pkg_file.File) {
final name = p.relative(f.path, from: zoneinfoPath);
final name = p.relative(f.path, from: zoneinfoPath).replaceAll('\\', '/');
log.info('- $name');
db.add(tzfileLocationToNativeLocation(
tzfile.Location.fromBytes(name, await f.readAsBytes())));
Expand Down
Loading