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

[Xamarin.Android.Build.Tasks] CopyIfChanged use last "write" time #1968

Merged
merged 2 commits into from
Jul 17, 2018

Conversation

jonathanpeppers
Copy link
Member

Fixes: #1962

Since 0adf1ae, I believe that resource changes on macOS have been
flaky--sometimes working, sometimes not. They have been consistenly
working on Windows, however...

After writing the simplest test I could, I found that my machine on
High Sierra could sometimes reproduce what our QA team was seeing. I
had to add the [Repeat] NUnit attribute before I could get the
failure to occur regularly.

After debugging for quite some time, I noticed a mistake in the
CopyIfChanged task. When comparing timestamps, it looks like it is
using the last access time of the destination file instead of the
last write time!

I think this is likely a typo (unintended), since switching the call
to GetLastWriteTimeUtc fixes the problem. Keeping the test is a good
idea, because it seems a bit scary we didn't catch this yet...

@jonpryor
Copy link
Member

From the "obvious question is obvious" department: there are currently 7 uses of File.GetLastAccessTimeUtc() in xamarin-android:

$ git grep File.GetLastAccessTimeUtc
src/Xamarin.Android.Build.Tasks/Tasks/CopyAndConvertResources.cs:                                       var dstmodifiedDate = File.Exists (destfilename) ? File.GetLastAccessTimeUtc (destfilename) : DateTime.MinValue;
src/Xamarin.Android.Build.Tasks/Tasks/CopyAndConvertResources.cs:                               var dstmodifiedDate = File.Exists (destfilename) ? File.GetLastAccessTimeUtc (destfilename) : DateTime.MinValue;
src/Xamarin.Android.Build.Tasks/Tasks/CopyIfChanged.cs:                         var dstmodifiedDate = File.Exists (dest) ? File.GetLastAccessTimeUtc (dest) : srcmodifiedDate;
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs:                         var lastTime = File.GetLastAccessTimeUtc (pdbToMdbPath);
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs:                                 File.GetLastAccessTimeUtc (pdbToMdbPath),
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs:                         var lastTime = File.GetLastAccessTimeUtc (pdbToMdbPath);
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs:                                 File.GetLastAccessTimeUtc (pdbToMdbPath),

Are these also problematic? I suspect that they are.

@dellis1972
Copy link
Contributor

The build errors are

error : Could not find file "/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/bin/TestDebug/TestResult-Mono.Android_Tests.xml"

looks like that is caused by

CHECKADBTARGET : error : no devices/emulators found [

Hmm

@dellis1972
Copy link
Contributor

build

@dellis1972
Copy link
Contributor

Thats a serious number of typo's :(

@jonathanpeppers
Copy link
Member Author

Arg conflicts...

Fixing it.

Fixes: dotnet#1962

Since 0adf1ae, I believe that resource changes on macOS have been
flaky--sometimes working, sometimes not. They have been consistenly
working on Windows, however...

After writing the simplest test I could, I found that my machine on
High Sierra could *sometimes* reproduce what our QA team was seeing. I
had to add the `[Repeat]` NUnit attribute before I could get the
failure to occur regularly.

After debugging for quite some time, I noticed a mistake in the
`CopyIfChanged` task. When comparing timestamps, it looks like it is
using the last *access* time of the destination file instead of the
last *write* time!

I think this is likely a typo (unintended), since switching the call
to `GetLastWriteTimeUtc` fixes the problem. Keeping the test is a good
idea, because it seems a bit scary we didn't catch this yet...
I suspect that none of these intentional.
@jonpryor jonpryor merged commit b4abdd9 into dotnet:master Jul 17, 2018
jonpryor pushed a commit that referenced this pull request Jul 17, 2018
…1968)

Fixes: #1962

Since 0adf1ae, I believe that resource changes on macOS have been
flaky: sometimes working, sometimes not. They have been consistently
working on Windows, however...

After writing the simplest test I could, I found that my machine on
High Sierra could *sometimes* reproduce what our QA team was seeing.
I had to add the `[Repeat]` NUnit attribute before I could get the
failure to occur regularly.

After debugging for quite some time, I noticed a mistake in the
`<CopyIfChanged/>` task: when comparing timestamps, it looks like it
is using the last *access* time of the destination file instead of
the last *write* time!

I think this is likely a typo (unintended), since switching the call
to `File.GetLastWriteTimeUtc()` fixes the problem.  Keeping the test
is a good idea, because it seems a bit scary we didn't catch this yet.

With that discovery, we audited the rest of the codebase and found
that we were using `File.GetLastAccessTimeUtc()` in several places.
We have deemed these *all* to be accidental, and have replaced all
occurrences of `File.GetLastAccessTimeUtc()` with
`File.GetLastWriteTimeUtc()`.
@jonathanpeppers jonathanpeppers deleted the copyifchanged-facepalm branch July 31, 2018 16:49
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UpdateAndroidResgen target is skipped on High Sierra and Win 10 after touching a resource file
3 participants