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

fix #13222: make relativePath more robust and flexible #13451

Merged
merged 9 commits into from
Apr 21, 2020

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Feb 21, 2020

@Araq
Copy link
Member

Araq commented Feb 21, 2020

Oh no. I don't want to expose getCurrentDir in the VM. It is a recipe for desaster builds that need a specific environment/setup. If you do nim c -r tests/foobar.nim or cd tests && nim c -r foobar.nim shouldn't be different, both should work equally well.

@timotheecour
Copy link
Member Author

Oh no. I don't want to expose getCurrentDir in the VM

removed it to unblock this PR; I understand the concern and this could be addressed similarly to cpuTime (where reproducible builds was the concern) via something analog to

  if optBenchmarkVM in c.config.globalOptions:
    wrap0(cpuTime, timesop)
  else:
    proc cpuTime(): float = 5.391245e-44  # Randomly chosen
    wrap0(cpuTime, timesop)

for users who understand that and still need the feature, but I've left this out of this PR to unblock it

@timotheecour timotheecour force-pushed the pr_fix_13222_relativePath_etc branch 2 times, most recently from a854c9f to ceda7d7 Compare February 22, 2020 09:05
@timotheecour
Copy link
Member Author

timotheecour commented Feb 22, 2020

PTAL:

@disruptek
Copy link
Contributor

We talked about adding getCurrentDir for bump's use-case. I would use this in nimph and testutils and golden and openapi, too. I guess I'm just a bad person.

I think you have to concede that if this isn't provided, a work-around will be developed, and that's clearly a worse option. Can you really champion NimScript as the right tool for writing build scripts when one cannot even find the current working directory in NimScript?

@Araq
Copy link
Member

Araq commented Feb 23, 2020

  1. It shouldn't have been part of this PR.
  2. The feature must be called staticGetCurrentDir or similar to prevent accidents like const x = getCurrentDir(). And we had real bugs like that in the past, it's why I changed my mind on these things. I'm not evil. ;-)

@Araq
Copy link
Member

Araq commented Feb 23, 2020

This patch that is really hard to review. Can't you achieve the same without rewriting the code?

@timotheecour
Copy link
Member Author

timotheecour commented Feb 23, 2020

This patch that is really hard to review. Can't you achieve the same without rewriting the code?

I agree it's hard to review but it's due to github diff view not dealing well with blocks of code being re-indented, I did not rewrite the code.

I know 2 options:

hidden github feature: ?w=1

I've just found a really interesting solution: adding ?w=1 which I say here https://github.blog/2011-10-21-github-secrets/
As you can see in https://github.com/nim-lang/Nim/pull/13451/files?w=1 I did not rewrite code, it's just re-indentation change; this should be super helpful in other code reviews.

caveat: this solution is a bit blunt, see caveats here: timotheecour#37

git diff --color-moved-ws=allow-indentation-change --color-moved=blocks

This is the hint I added to https://nim-lang.github.io/Nim/contributing.html which helps if you locally fetch the PR, it helps by coloring differently code that was moved.
see caveats here: timotheecour#37

lib/pure/os.nim Show resolved Hide resolved
lib/pure/os.nim Show resolved Hide resolved
changelog.md Outdated Show resolved Hide resolved
@timotheecour
Copy link
Member Author

timotheecour commented Feb 26, 2020

PTAL (you can just review last 2 commits)

changelog.md Outdated Show resolved Hide resolved
lib/pure/os.nim Show resolved Hide resolved
@Araq
Copy link
Member

Araq commented Feb 27, 2020

You missed to update tests/js/tos.nim

@timotheecour
Copy link
Member Author

You missed to update tests/js/tos.nim

done, PTAL (and see comments above)

@Araq
Copy link
Member

Araq commented Apr 21, 2020

Gah, I screwed up the changelog cleanup...

@timotheecour
Copy link
Member Author

timotheecour commented Apr 21, 2020

@Araq

Gah, I screwed up the changelog cleanup...

TLDR: we should rebase, not merge

I've rebased (instead of merged) to keep git history linear. Merge makes it really hard to understand individual commits as they get mixed with unrelated changes (even if this is squashed + merged in github UI, the individual commits of PR can still be seen in github UI, and are useful to follow the PR.

@disruptek

We talked about adding getCurrentDir for bump's use-case. I would use this in nimph and testutils and golden and openapi, too. I guess I'm just a bad person.

this is now possible since #13813 via --experimental:vmopsDanger

@timotheecour timotheecour mentioned this pull request Apr 21, 2020
1 task
@timotheecour timotheecour reopened this Apr 21, 2020
@Araq Araq merged commit 7ce0358 into nim-lang:devel Apr 21, 2020
@timotheecour timotheecour deleted the pr_fix_13222_relativePath_etc branch April 21, 2020 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

relativePath("foo", "/") and relativePath("/", "foo") is wrong
3 participants