Commit Graph
113 Commits
Author SHA1 Message Date
Hsiao-nan Cheung 5f91682a79 decompress.ps1: Refactored (w/ install.ps1, core.ps1) (edited) (#3169)
* decompress.ps1: Refactored (w/ install.ps1, core.ps1)

* fix install.ps1
2019-03-07 22:14:06 +01:00
Richard Kuhnt 7bedd449b5 validator: Improve error reporting, add support for multiple files
- Display clickable links to directly jump to error line
- Display invalid JSON path
- Dynamic error nesting
- Support for validation multiple files 
  e.g. `validator.exe .\schema.json .\bucket\*.json`
  or `validator.exe .\schema.json .\manifest1.json .\manifest2.json`
2019-02-24 13:20:44 +01:00
Vladimir Chebotarev da64301b8b [core] Allowed underscores in package names. (#2930)
* Allowed underscores in package names.

* Added tests for underscores in package names.
2019-02-22 19:12:48 +01:00
Chawye Hsu d23552a5a5 Rewritten data persisting feature (#2897)
**Data matters, please review**

This is a rework of #2891 #2890 and #2882 . This will also fix #2724 and fix #2900 , close #2779 

**Introduction**

I add a function called `unlink_persist_data($dir)`, which recursively unlink all junction/hard link in the given directory. This affects some sub-commands which have interaction with junction/hard link:

- `scoop-install`: the persisting logic has been improved as follow:
  1. if there are data in the `persist` folder, also in app(`source`) folder, rename that one located in app folder (e.g. app's default setting files) with a `original` suffix, then create link from `persist` to  app
  2. if there are data in the `persist` folder, but no in app(`source`) folder, just create link from `persist` to  app
  3. if there is no data in the `persist` folder (e.g. fresh install), but there are data in app(`source`) folder (e.g. app's default setting files), we will just use that default setting files as the first-time persisting. So move that files from app folder to `persist` folder, then create link from `persist` to  app
  4. But what if if there is neither data in the `persist` folder (e.g. fresh install), nor in the app(`source`) folder (e.g. setting files will be created after first startup, like `Everthing.db`). We need to create empty persisting target in the `persist` folder. But by default we can't know if a persisting target is a file or a directory (e.g. `conf.d`). So we create a directory by default, and to avoid this, manifest maintainers should use `pre_install` to manually create the source file before persisting.
- `scoop-reset`: `reset` command uses the logic of `install`, but there is a problem: before re-persisting data, there have been `junction/hard link` in the app(`source`) folder. It will throw an exception of file exists #2724 . To fix this, we should unlink all old link before re-persisting, using `unlink_persist_data`.
- `scoop-uninstall`: `Remove-Item` can not remove `NTFS junction`, we need to unlink all persistting data, before uninstalling/deleting an app, but keeping persisting data.
- `scoop-cleanup`: like `uninstall`, `Remove-Item` can not remove `NTFS junction`, we need to unlink all persistting data, before deleting old versions of an app. Before PR #2882 , it use `fsutil.exe` to unlink junction, which is not friendly to restricted users (#2832 and #2881 ).

Beyond the logic improvement, there is a new feature now: it supports sub-folder data persisting, like:

```json
{
    "homepage": "https://scoop.sh",
    "description": "A dummy manifest for scoop tests.",
    "license": "Freeware",
    "version": "1.1.0",
    "url": "https://get.scoop.sh",
    "pre_install": [
        "if (!(test-path \"$dir\\dummy.txt\")) { new-item -force \"$dir\\dummy.txt\" -itemtype file | out-null }",
        "if (!(test-path \"$dir\\dummydir\")) { new-item \"$dir\\dummydir\" -itemtype directory | out-null }",
        "if (!(test-path \"$dir\\subdir\")) { new-item \"$dir\\subdir\" -itemtype directory | out-null }",
        "if (!(test-path \"$dir\\subdir\\subdummydir\")) { new-item \"$dir\\subdir\\subdummydir\" -itemtype directory | out-null }",
        "if (!(test-path \"$dir\\subdir\\subdummy.txt\")) { new-item -force \"$dir\\subdir\\subdummy.txt\" -itemtype file | out-null }",
    ],
    "persist": [
        "dummy.txt",
        "dummydir",
        "subdir\\subdummydir",
        "subdir\\subdummy.txt"
    ]
}
```
So no need to strip directories of source for target anymore.

To participate in the code review and tests, go visit https://github.com/h404bi/scoop-persist-test for test cases.
2019-01-17 18:00:29 +01:00
Richard Kuhnt 589303facc tests: Fix manifest tests for buckets
- Fixes a bug introduced with 478f52c421 that broke manifest tests on other buckets
- Allows testing "bucket" subdirectory for buckets
2018-12-22 15:05:08 +01:00
Richard Kuhnt 478f52c421 tests: Add importable tests for Buckets 2018-12-16 15:55:32 +01:00
Richard Kuhnt 7b7113fc3b tests: Move style constraints tests to separate test file
- This allows importing these tests in other buckets
- Simpler UTF-8 BOM reading function
2018-12-16 15:53:05 +01:00
Richard Kuhnt 53e73f5211 appveyor: Remove trailing comma from params
Regression from f857dce9f5
2018-12-16 14:51:52 +01:00
Richard Kuhnt f857dce9f5 appveyor: Add -TestPath param to test.ps1 2018-12-16 14:49:53 +01:00
Richard Kuhnt 7a1b5a1840 appveyor: Force install PSScriptAnalyzer and BuildHelpers 2018-12-16 14:13:16 +01:00
Richard Kuhnt dde4d0f93f appveyor: Update BuildHelpers to version 2.0.1 2018-12-16 14:11:36 +01:00
Jakub Čábera 3e1649553d formatjson.ps1: Format single value Arrays into String (#2642)
- Automatically convert single value arrays and recursively normalize PSObjects values
- Add tests
- Add .yml .editorconfig settings
2018-11-13 20:49:20 +01:00
Kevin Marquette c0dce0e8cd Use Pester 4.0 syntax to multiple files (#2714) 2018-10-29 14:59:03 +01:00
Kevin Marquette b37349a531 Use pester 4.0 syntax to the install tests (#2713)
This PR updates the `should` Pester calls with the 4.0 syntax in the `Scoop-Install.Tests.ps1` file
2018-10-29 14:58:51 +01:00
Kevin Marquette 9d6c02ac68 Use pester 4.0 syntax in core tests (#2712) 2018-10-29 14:58:29 +01:00
Richard Kuhnt ac3ee76672 appveyor: require BuildHelpers version 2.0.0 2018-09-18 18:47:42 +02:00
Richard Kuhnt c0295f0ae0 appveyor: Run tests for PowerShell 5 and 6 (#2603)
- Adds `!linter` commit flag to skip PSScriptAnalyzer
- Adds `!manifests` commit flag to skip manifest validation
- Skips manifest validation if no JSON has changed
- Skips tests and linting if no PowerShell script has changed
- Validates only manifests that changed
- Validates all manifests if `schema.json` changed
2018-09-18 18:37:43 +02:00
Leon Yu 9bc7d5f8b3 Fix .ps1 shim parsing logic due to prior PR (#2564)
Due to my prior PR #2562 which changed the content of .ps1 shims, the code that attempts to warn about shims being overwritten no longer detects app name correctly. This is to correct that.
2018-09-07 16:25:37 +02:00
Richard Kuhnt 4ed6265ed7 Add some tests for scoop config 2018-08-07 20:11:38 +02:00
Richard Kuhnt ff9c0c3daf parse_app(): fix for relative paths 2018-05-07 14:18:40 +02:00
Richard Kuhnt 70f64c8f4b Refactor app() to parse_app() for better "bucket/app@version" handling (#2234)
It now parses these app names:
- php-bucket/php71-amqp@1.8.0
- php-bucket/php71-amqp
- php71-amqp@1.8.0
- php71-amqp@1.9.0-rc2

Removed:
- is_app_with_specific_version()
- get_app_with_version()
2018-05-04 21:51:43 +02:00
Chawye Hsu c3df0f8398 Expose bucketdir variable in manifest test script (#2182) 2018-04-08 01:19:48 +02:00
Leon Yu 71da515b82 Fix some tests on linux (#2153)
* fix bom reading test in PowerShell 6

* Use join-path to fix test on Linux
2018-04-04 18:14:27 +02:00
Chawye Hsu 731247876d [Pending] Finally we add the code linting and its tests! (#2108)
* Lint: PSPossibleIncorrectComparisonWithNull

* Lint: PSUseLiteralInitializerForHashtable

* Lint: PSUseBOMForUnicodeEncodedFile

* Lint: PSUseApprovedVerbs

* Lint: PSAvoidGlobalVars

* Lint: PSAvoidUsingEmptyCatchBlock

* Lint: PSUseShouldProcessForStateChangingFunctions

* Lint helper: Add PSScriptAnalyzer integration for vscode

* Fix lint: PSUseBOMForUnicodeEncodedFile

* Tests: ignore previous TestResults.xml

* Tests: add PowerShell script linting into tests!

* Add PSScriptAnalyzer into appveyor ci

* Update Scoop-Linting.Tests.ps1
2018-03-13 14:26:55 +01:00
Chawye Hsu e1bb1e91d0 Lint: PSAvoidUsingCmdletAliases (#2075) 2018-03-03 18:41:19 +01:00
Richard Kuhnt f0a15886f2 Update validator.exe and shim.exe (#2024)
* Update Newtonsoft.Json and improve validator build process

* Improve shimexe build process and create deterministic builds
2018-02-20 18:48:02 +01:00
Richard Kuhnt 36dc7a880c Allow more architecture naming conventions for --arch parameters
closes #1908
2017-12-15 17:05:12 +01:00
Richard Kuhnt da7d61f3e3 Use Get-FileHash instead of System.Security.Cryptography.HashAlgorithm (#1725)
* Use Get-FileHash instead of System.Security.Cryptography.HashAlgorithm if available

This satisfies these two cases:
* PowerShell 3 doesn't support Get-FileHash
* PowerShell 6 doesn't support HashAlgorithm yet

* Add tests for compute_hash() function
2017-12-12 13:12:48 +01:00
Richard Kuhnt 872517b898 Update tests to work with pester version 4.* (#1711)
* Remove custom choco options
* Use Install-Module to install Pester
2017-11-27 15:27:38 +01:00
Richard Kuhnt 54ec3365f2 Don't set $env:TEMP on unix, instead use /tmp as workingdir for tests 2017-05-31 01:35:51 +02:00
Richard Kuhnt 8a746c8678 Ignore .DS_Store in tests 2017-05-31 01:02:48 +02:00
Richard Kuhnt 641dd70011 Fix unzip_old test 2017-05-31 00:50:15 +02:00
Richard Kuhnt f982068d4f Small path fixes to make manifest tests pass on unix 2017-05-30 22:12:50 +02:00
Richard Kuhnt f737315e73 Merge pull request #1517 from lukesampson/unix-compatible
[WIP] Add Unix compatibility (for maintenance jobs and manifest testing)
2017-05-30 21:59:15 +02:00
Luke Sampson 887f041fc7 Extract to _tmp instead of _scoop_extract to conserve 10 more characters in path. 2017-05-29 17:59:09 +10:00
Richard Kuhnt 24fd3a3c7e Move unix compatible functions to unix.ps1
- Change helper functions to snake_case
2017-05-28 13:59:42 +02:00
Richard Kuhnt 4f4e5d18d7 Skip tests heavily relying on robocopy and windows paths 2017-05-27 17:18:14 +02:00
Richard Kuhnt 5b4b2fce99 Some path fixes for unix 2017-05-27 17:12:37 +02:00
Richard Kuhnt 59139bae04 Use remove-item/copy-item instead of rm/cp to resolve unix conflicts
Powershell aliases for rm/cp will not work, because the system commands are used
2017-05-27 17:12:12 +02:00
Richard Kuhnt 139813a8f5 Tests: handle JSON.NET schema validation limit exceeded.
Copied from extras bucket
2017-05-27 16:51:02 +02:00
Richard Kuhnt a9dfea5cf0 Fix manifest tests for pester v4 2017-05-27 16:26:58 +02:00
Richard Kuhnt 404f9be2f2 Fix repo_dir not being set correctly 2017-05-07 20:52:58 +02:00
Rémy 0a21edd0d5 add tests for some version edge cases 2017-04-03 19:41:52 +02:00
Rémy bf23c300ae add tests for shim_def 2017-04-03 19:12:21 +02:00
Rémy 822239335b add tests for is_in_dir 2017-04-03 19:06:49 +02:00
Rémy 303c1e43f2 add tests for various file name functions 2017-04-03 18:53:14 +02:00
Rémy a5b6d86134 add tests for ensure_architecture 2017-04-03 18:46:13 +02:00
Rémy 0fff49f89e create test file for install / add test for env_add|rm_path 2017-04-03 18:40:06 +02:00
Rémy 807fcb0ebd fix tests 2017-03-30 00:42:19 +02:00
Rémy 357b33ddfe persist file support 2017-03-25 16:28:06 +01:00